我有编译错误只是输出cout
消息。以下是我的代码:
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
char letter = 'a';
short age = 10;
int cout = 575;
long numStars = 985632145;
float pi = 3.1;
double price = 89.65;
string season = "summer";
cout << "Letter: "<< letter << endl;
std::cout << "Age: " << age<< endl;
std::cout << "Cout: " << cout << endl;
std::cout << "Number Stars: " << numStars << endl;
std::cout << "Pi: " << pi << endl;
std::cout << "Price: " << price << endl;
std::cout << "Season: " << season;
system("pause");
return 0;
}
我得到的错误就行了:
cout << "Letter: "<< letter << endl;
我尝试重新安装VS2015,但这没有帮助。
答案 0 :(得分:2)
您有一个名为int
的{{1}}类型的变量 - 鉴于您是cout
,这是不允许的。将此变量名称更改为其他名称,并避免使用语句using namespace std。
using namespace std
是“保留类型/关键字”,因此您无法将其用作变量名称。