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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM