不在VS上运行但在Dev C ++上运行

时间:2017-08-23 09:33:14

标签: c++ visual-studio visual-c++

我一直试图在VS上运行这个基本程序。代码在

之下
#include<iostream>
using namespace std;

class student
{
public:
    int id;
    string name;
};
int main()
{
    student s1, s2;
    s1.id = 10;
    s1.name = "ayudh";
    s2.id = 20;
    s2.name =  "pooja";
    cout << s1.id << endl ;
    cout << s1.name << endl;
    cout << s2.id << endl;
    cout << s2.name << endl;
    system("pause");

}

当我尝试运行它时,我收到错误“No operator”&lt;&lt;“匹配此操作数”。 有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:3)

你错过了

#include <string>

位于文件顶部。

相关问题