class Student
{
public:
void setName(_strname)
{m_strName=_strname;}
string getName( )
{
return m_strName;
}
private:
string m_strName;
};
int main()
{Student *str = new Student();
str->setName("慕课网");
cout<<getName( )<<endl;
delete str;
str=NULL;
return 0;
}
{
public:
void setName(_strname)
{m_strName=_strname;}
string getName( )
{
return m_strName;
}
private:
string m_strName;
};
int main()
{Student *str = new Student();
str->setName("慕课网");
cout<<getName( )<<endl;
delete str;
str=NULL;
return 0;
}
#include <iostream>
#include <string>
using namespace std;
class Student
{
public:
string m_strName;
int m_iAge;
};
int main()
{
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;
stu.m_strName = "慕课网";
stu.m_iAge = 2;
cout <<stu.m_strName<< " " <<stu.m_iAge<< endl;
return 0;
}
最赞回答 / 慕粉4367945
老师讲课时没有强调,在剪切完的程序中要加一行#include "Teacher.h",这是我做下一节是领悟的,其实,今天早上我就觉得这三个分开的部分不能相互联系好像少了什么,慕课网不错,尤其坚持学习下去,对慕课网点个赞,同时感谢一直互相帮助的慕友。
2017-01-19
最赞回答 / qq_风起天阑
这句话说的是两种情况:一,没有自定义的构造函数时系统自动生成默认的构造函数;二,自定义的默认构造函数分两种,不带参数的和参数都带默认值的,这些构造函数都可以用来实例化对象
2017-01-16