// 更改对象的数据成员为“慕课网”
这一行字里面 “慕课网”的引号用的是全角符号,直接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;
}