C++ 继承函数

#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; }

 

posted @ 2020-02-18 10:38  神迹丶  阅读(1356)  评论(0编辑  收藏  举报
网站已运行: