我正在尝试学习 c++,但不存在像“cout”和“cin”这样的简单方法,这是我的代码:
#include "stdafx.h"
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{
cout>>"hello";
return 0;
}
有一个错误提示“错误 C2065:'cout':未声明的标识符”
和“IntelliSense:标识符“cout”未定义”
我正在尝试学习 c++,但不存在像“cout”和“cin”这样的简单方法,这是我的代码:
#include "stdafx.h"
#include <iostream>
int _tmain(int argc, _TCHAR* argv[])
{
cout>>"hello";
return 0;
}
有一个错误提示“错误 C2065:'cout':未声明的标识符”
和“IntelliSense:标识符“cout”未定义”
cout在std命名空间中声明:
int _tmain(int argc, _TCHAR* argv[])
{
std::cout << "hello";
return 0;
}
你也做错了。请注意我上面的尖括号。
添加#include <iostream>到stdafx.h. 我遇到了麻烦,它对我有用。
添加using namespace std;可能会有所帮助,但也cout << "hello"不会>>。
coutstd这样你就有用了using namespace std。而对于cout运营商来说就像<<. >> 这是用于输入,即cin。
#include "stdafx.h";
#include "iostream";
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
cout<<"hello";
system("pause");
return 0;
}