:C++プログラム、次のエラーを検出することができません:私は、次のC++のプログラムを書かれている
#include <iostream>
using namespace std;
string s1 = "Hello";
int main() {
string s2 = "World";
cout << s1 << " " << s2 << endl;
int s1 = 46;
cout << s1 << " " << s2 << endl;
cout << "hello" " " "mars" << endl;
message();
return 0;
}
void message(void) {
cout << s1 << " World" << endl;
}
コンパイラは私に次のエラー表示されます。
24.cpp:12:2: error: ‘message’ was not declared in this scope
message();
をしかし、私はいつものような機能を使用していますこの。私はmain()
の機能の外にmessage()
の機能を宣言して定義し、それをmain()
という機能で呼びました。
どこが間違っていますか?
'main 'の上に' void message(); 'を追加し、' void message(void){'をvoid message(){'に変更してください。 – DimChtz
私はなぜこれがdownvoted理由が表示されません。 – arrowd
@arrowdなぜ「このコードは動作しないのですか?」という質問があり、 – SourceOverflow