【发布时间】:2014-11-21 20:57:36
【问题描述】:
在Dev C++ 编译器中,我可以编写并成功编译:
#include <iostream>
#include <string>
using namespace std;
int main ()
{
string method;
cin >> method;
return 0;
}
但是当我在Visual Studio 2013 (console app mode) 中编写上面的代码时,我得到了这个错误:
Error: no operator ">>" matches these operands
operand types are: std::istream >> std::string
编辑
在Visual Studio:
#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
string method;
cin >> method;
return 0;
}
我明白错误告诉我什么。但为什么只有Visual Studio 2013?
【问题讨论】:
-
您的代码在我的 VS 2013 中编译没有问题。也许您在新项目中尝试一下?
-
感谢关注,但这是我的错误。我忘记了项目第一行的“#”。
标签: c++ visual-studio-2013 dev-c++