2017-08-23 94 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> 

在文件的頂部。

相關問題