写这个代码,它完美的工作..
#include "stdafx.h" #include using namespace std; int main() { cout<
在Visual Studio中,您必须#include "stdafx.h"并且是cpp文件的第一个包含。 例如:
这些将不起作用。
#include using namespace std; int main () { cout << "hey" << endl; return 0; } #include #include "stdafx.h" using namespace std; int main () { cout << "hey" << endl; return 0; }
这会做。
#include "stdafx.h" #include using namespace std; int main () { cout << "hey" << endl; return 0; }
我在Visual Studio C ++ 2010上遇到了同样的问题。修复起来很简单。 在main()函数的上面,用下面的代码replace标准的include行,但在include前面用磅符号。
# include "stdafx.h" # include using namespace std;
我已经看到,如果你使用
#include
那么你会得到这个问题。
如果你使用
#include
(注意 – 没有.h)
那么你不会遇到你提到的问题。
include