我只是想让自己熟悉从Java迁移过来的C++的基础知识。我刚刚写了这个功能禁用程序,遇到了一个错误的test.cpp:15: error: expected primary-expression before ‘<<’ token,我不确定为什么。
有人愿意解释一下为什么endl不使用常量吗?代码如下。
//Includes to provide functionality.
#include <iostream>
//Uses the standard namespace.
using namespace std;
//Define constants.
#define STRING "C++ is working on this machine usig the GCC/G++ compiler";
//Main function.
int main()
{
string enteredString;
cout << STRING << endl;
cout << "Please enter a String:" << endl;
cin >> enteredString;
cout << "Your String was:" << endl;
cout << enteredString << endl;
return(0);
}发布于 2011-07-12 04:43:23
请删除#define STRING末尾的;,然后重试。
https://stackoverflow.com/questions/6656246
复制相似问题