为了账号安全,请及时绑定邮箱和手机立即绑定
有Java基础会简单一些
瞎打都可以过什么鬼
苟。。苟富贵,勿相忘
想把电脑砸了 支持的点歌赞
5岁大的老师?
dema.cpp 和 teacher.cpp什么关系啊??
dongdongdongdong~~~
这个验证答案是有问题的,输出里面必须包含慕课网!!!
程序员很累啊!
class Student
{
public:
// 定义数据成员封装函数setName()
void setName(string _name)
{
m_strName=_name;
}


// 定义数据成员封装函数getName()
string getName(void)
{
return m_strName;
}


//定义Student类私有数据成员m_strName
private:
string m_strName;

};
string不是类型,是类,它和容器很像,可以把它和vector这样的容器比较着使用
Student() {
cout << "Student()" << endl;
}
explicit Student(string name) {
m_strName = name;
cout << "Student(string name)" << endl;
}
Student(const Student& stu) {
cout << "Student(const Student& stu)" << endl;
}
int main(void)
{
Student *stu = new Student("张晨飞");
Student *stu1 = new Student("张晨飞");
Student *stu2(stu1);
stu->setName("慕课网");
cout<<"学生名字:"<<stu->getName()<<endl;
cout<<"学生名字:"<<stu2->getName()<<endl;
delete stu2,stu,stu1;
stu=stu1=stu2=NULL;
return 0;
}
必须得把慕课网放到第一个输出
class Student
{
public:
Student(){}
Student(string _name){m_strName=_name;}
Student(const Student& stu){}
~Student(){}
void setName(string _name){m_strName=_name;}
string getName(){return m_strName;}
private:
string m_strName;
};
/* copyright */
#include <iostream>
#include <string>
using std::cout;
using std::endl;
using std::string;
class Student {
public:
void setName(string _name) {
m_strName = _name;
}
string getName() {
return m_strName;
}
private:
string m_strName;
};
课程须知
本课程是C++初级课程 需要熟练掌握C++语言基础语法
老师告诉你能学到什么?
1、类的定义与对象实例化 2、string类型及属性封装 3、类外定义 4、构造函数与初始化列表 5、析构函数

微信扫码,参与3人拼团

微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

友情提示:

您好,此课程属于迁移课程,您已购买该课程,无需重复购买,感谢您对慕课网的支持!

本次提问将花费2个积分

你的积分不足,无法发表

为什么扣积分?

本次提问将花费2个积分

继续发表请点击 "确定"

为什么扣积分?

举报

0/150
提交
取消