老師,您好,請問這個代碼為什么編譯不了,錯在那,謝謝
#include <iostream>
#include <string>
using namespace std;
/**
? * 定義類:Student
? * 數據成員:名字、年齡
? */
class Student
{
public:
? ? // 定義數據成員名字 m_strName 和年齡 m_iAge
? ? string m_strName;
? ? int m_iAge;
};
int main()
{
? ? // 實例化一個Student對象stu
? ? Student stu;
? ? // 設置對象的數據成員
? ? stu.m_strName = "慕課網";
? ? stu.m_iAge = 2;
? ??
? ? // 通過cout打印stu對象的數據成員
? ? cout << stu.m_strName << " " << stu.m_iAge<< endl;
? ? return 0;
}
2019-04-23
這個沒有問題吧
2015-08-25
報的什么錯,是不是你建工程的步驟不對?
2015-05-31
沒有錯啊,我復制可以執行。而且有結果