指针那块老有问题,有大神能够解答问题吗?
#include <iostream>
#include <string>
#include<stdlib.h>
using namespace std;
class Student
{
public:
// 定义数据成员封装函数setName()
Student();
Student(string name);
void setName(string _name);
string getName();
Student(const Student &tea);
~Student();
private:
string m_strName;
};
int main(void)
{
// 通过new方式实例化对象*stu
Student *stu = new Student();
// 更改对象的数据成员为“慕课网”
stu->m_str_Name = "慕课网";
// 打印对象的数据成员
cout << "stu->m_strName>" << endl;
return 0;
}
Student::Student() :m_strName(name)
{
m_strName = "JIM";
}
void Student::setName(string _name)
{
m_strName = _name;
}
string Student::getName()
{
return m_strName;
}
Student::Student(const Student&tea)
{
cout << "Student(const Student&tea)" << endl;
};
Student::~Student()
{
}