質問編集履歴
3
助言により、msg.cppからr_msg.cppをインクルードするように変更
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -6,7 +6,14 @@
|
|
|
6
6
|
### 発生している問題・エラーメッセージ
|
|
7
7
|
|
|
8
8
|
```
|
|
9
|
+
重大度レベル コード 説明 プロジェクト ファイル 行 抑制状態
|
|
9
|
-
|
|
10
|
+
エラー C2461 'msg': コンストラクターに、仮引数が指定されていません。 msg.h
|
|
11
|
+
エラー C4430 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません。 r_msg.h
|
|
12
|
+
エラー C2146 構文エラー: ';' が、識別子 'retMsg2' の前に必要です。 r_msg.h
|
|
13
|
+
エラー C2461 'msg': コンストラクターに、仮引数が指定されていません。 msg.h
|
|
14
|
+
エラー C4430 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません。 r_msg.h
|
|
15
|
+
エラー C2146 構文エラー: ';' が、識別子 'retMsg2' の前に必要です。 r_msg.h
|
|
16
|
+
エラー C2461 'msg': コンストラクターに、仮引数が指定されていません。 msg.h
|
|
10
17
|
```
|
|
11
18
|
|
|
12
19
|
### 該当のソースコード
|
|
@@ -14,37 +21,40 @@
|
|
|
14
21
|
```c++
|
|
15
22
|
/** main.cpp **/
|
|
16
23
|
#include "msg.h"
|
|
17
|
-
msg retMsg1(){//エラーは発生しない
|
|
18
|
-
msg Msg;
|
|
19
|
-
return Msg;
|
|
20
|
-
}
|
|
21
24
|
|
|
22
|
-
int main(){
|
|
25
|
+
int main() {
|
|
26
|
+
|
|
23
|
-
|
|
27
|
+
return 0;
|
|
24
28
|
}
|
|
25
29
|
```
|
|
26
30
|
```header
|
|
31
|
+
#pragma once
|
|
27
32
|
/** msg.h **/
|
|
28
33
|
#ifndef _MSG_
|
|
29
34
|
#define _MSG_
|
|
35
|
+
#include <string>
|
|
30
36
|
#include "r_msg.h"
|
|
37
|
+
using namespace std;
|
|
38
|
+
|
|
39
|
+
struct msg {
|
|
40
|
+
string msg = "";
|
|
41
|
+
};
|
|
31
42
|
#endif
|
|
32
|
-
extern struct msg {
|
|
33
|
-
string msg = "";
|
|
34
|
-
};
|
|
35
43
|
```
|
|
36
44
|
```header
|
|
45
|
+
#pragma once
|
|
37
46
|
/** r_msg.h **/
|
|
47
|
+
|
|
38
48
|
#include "msg.h"
|
|
39
|
-
msg retMsg2();
|
|
49
|
+
msg retMsg2();
|
|
40
50
|
```
|
|
41
51
|
```c++
|
|
42
52
|
/** r_msg.cpp **/
|
|
43
53
|
#include "r_msg.h"
|
|
44
54
|
|
|
45
|
-
msg retMsg2(){
|
|
55
|
+
msg retMsg2() {
|
|
46
|
-
|
|
56
|
+
msg Msg;
|
|
47
|
-
|
|
57
|
+
return Msg;
|
|
48
58
|
}
|
|
49
59
|
```
|
|
50
60
|
|
2
インクルードガードの追加
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -25,7 +25,10 @@
|
|
|
25
25
|
```
|
|
26
26
|
```header
|
|
27
27
|
/** msg.h **/
|
|
28
|
+
#ifndef _MSG_
|
|
29
|
+
#define _MSG_
|
|
28
30
|
#include "r_msg.h"
|
|
31
|
+
#endif
|
|
29
32
|
extern struct msg {
|
|
30
33
|
string msg = "";
|
|
31
34
|
};
|
1
r_msg.hへ#include "msg.h"の追加
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
```
|
|
33
33
|
```header
|
|
34
34
|
/** r_msg.h **/
|
|
35
|
+
#include "msg.h"
|
|
35
36
|
msg retMsg2();//エラーが発生する
|
|
36
37
|
```
|
|
37
38
|
```c++
|