#include <iostream>
using namespace std;
class passport
{
public:
passport() //默认构造
{
}
passport(int id,string tongxingzheng,string mima,string shenfen)
{
this->id = id;
this->pass = tongxingzheng;
this->password = mima;
this->shenfenzheng = shenfen;
}
~passport()//析构
{
}
protected:
//定义父类成员变量
int id;
string pass;
string password;
string shenfenzheng;
};
class xiaoming :public passport //子类继承父类passport的成员
{
public:
xiaoming(int id, string tongxingzheng, string mima, string shenfen)
{
this->id = id;
this->pass = tongxingzheng;
this->password = mima;
this->shenfenzheng = shenfen;
}
};
int main()
{
passport xiaoxiao(1,"xiaoxiao", "123456", "123456789");
xiaoming xiaoqi(2, "xiaoqi", "123456", "987654321");
return 0;
}
原文链接: https://www.cnblogs.com/shenji/p/12325139.html
欢迎关注
微信关注下方公众号,第一时间获取干货硬货;公众号内回复【pdf】免费获取数百本计算机经典书籍
原创文章受到原创版权保护。转载请注明出处:https://www.ccppcoding.com/archives/193274
非原创文章文中已经注明原地址,如有侵权,联系删除
关注公众号【高性能架构探索】,第一时间获取最新文章
转载文章受原作者版权保护。转载请注明原作者出处!