2017-08-23 60 views
0

我一直在试图在VS上运行这个基本程序。代码如下不在VS上运行,但在Dev C++上运行

#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"); 

} 

当我尝试运行它,我得到一个错误“不操作” < <“匹配这个操作数”。 有人可以帮我解决这个问题吗?

回答

3

你已经错过了

#include <string> 

在文件的顶部。

相关问题