回覆列表
  • 1 # 吾心願比之如

    #include<iostream>

    usingnamespacestd;

    classVehicle{

    public:

    virtualvoidRun(){cout<<"Vehicle::Runcalled\n";}

    virtualvoidStop(){cout<<"Vehicle::Stopcalled\n";}

    };

    classmotorcar:publicVehicle{

    public:

    voidRun(){cout<<"motorcar::Runcalled\n";}

    virtualvoidStop(){cout<<"motorcar::Stopcalled\n";}

    };

    classbicycle:publicVehicle{

    public:

    virtualvoidRun(){cout<<"bicycle::Runcalled\n";}

    voidStop(){cout<<"bicycle::Stopcalled\n";}

    };

    classmotorcycle:publicbicycle,publicmotorcar{

    public:

    voidRun(){cout<<"motorcycle::Runcalled\n";}

    voidStop(){cout<<"mototrcycle::Stopcalled\n";}

    };

    voidmain(){

    Vehicleve;

    bicyclebi;

    motorcarmo;

    motorcyclemocy;

    Vehicle*pclass=&ve;

    pclass->Run();

    pclass->Stop();

    pclass=&bi;

    pclass->Run();

    pclass->Stop();

    pclass=&mo;

    pclass->Run();

    pclass->Stop();

    }

  • 中秋節和大豐收的關聯?
  • 詹天佑的故事250字左右?