// 更改對象的數據成員為“慕課網”
這一行字里面 “慕課網”的引號用的是全角符號,直接copy到setName函數編譯過不了,找了半天才找到是這里問題。。。。
這一行字里面 “慕課網”的引號用的是全角符號,直接copy到setName函數編譯過不了,找了半天才找到是這里問題。。。。
#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
string m_strName;
int m_iAge;
};
int main()
{
// 實例化一個Student對象stu
Student stu;
stu.m_strName = "慕課網";
stu.m_iAge = 2;
cout << stu.m_strName << "," << stu.m_iAge<< endl;
return 0;
}
#include <string>
using namespace std;
class Student
{
public:
string m_strName;
int m_iAge;
};
int main()
{
// 實例化一個Student對象stu
Student stu;
stu.m_strName = "慕課網";
stu.m_iAge = 2;
cout << stu.m_strName << "," << stu.m_iAge<< endl;
return 0;
}