搜题
问题   更新时间2023/4/3 12:59:00

#include

using namespace std;

class base

{

private:int x;

public:base(int a){x=a;}

int get(){return x;}

void showbase() {cout<<"x="<<><>< strong="">



};

class Derived:public base

{private:int y;

public:Derived(int a,int b):base(a){y=b;}

void showderived()

{cout<<"x="<<>< strong="">



};

void main()

{

base b(3);

Derived d(6,7);

b.showbase();

d.showderived();

b=d;

b.showbase();

b1.showbase();

________________________

base* pb=&b1;

pb->showbase();

d.showderived();

b.showbase();

}

输出结果如下:

x=3

x=6,y=7

x=6

x=6

x=6

x=6,y=7

x=6

Derived b1(d);(或Derived b1(6,7); 或base b1(6);或 base b1(d);)
王老师:19139051760(拨打)