首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >带有常量的C++结尾

带有常量的C++结尾
EN

Stack Overflow用户
提问于 2011-07-12 04:39:37
回答 8查看 391关注 0票数 0

我只是想让自己熟悉从Java迁移过来的C++的基础知识。我刚刚写了这个功能禁用程序,遇到了一个错误的test.cpp:15: error: expected primary-expression before ‘<<’ token,我不确定为什么。

有人愿意解释一下为什么endl不使用常量吗?代码如下。

代码语言:javascript
复制
//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);
}
EN

Stack Overflow用户

发布于 2011-07-12 04:43:23

请删除#define STRING末尾的;,然后重试。

票数 1
EN
查看全部 8 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6656246

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档