#include <iostream>
using namespace std;
class A{
public:
int a;
A(int a):a(a){}
A():A(5){}
};
class B:virtual public A
{
public:
int b;
B(int b):A(),b(b){}
};
class C:virtual public A
{
public:
int c;
C(int c):A(),c(c){}
};
class D:public B,public C
{
public:
int d;
D(int b,int c,int d):B(b),C(c),d(d){}
};
class Father{
int* p;
const string name;
public:
Father():Father(180,"小头"){}
Father(int a,string b):p(new int(a)),name(b){}
Father(const Father& other):p(new int(*(other.p))),name(other.name){}
Father& operator=(const Father &other){
p=new int(*other.p);
return *this;
}
};
class son:public Father{
int* age;
public:
son():Father(),age(new int(6)){}
son(int age):Father(),age(new int(age)){}
using Father::Father;
son(const son &other):Father(other),age(new int(*other.age)){}
son& operator=(const son &other){
*age=*(other.age);
Father* a=this;
*a= other;
return *this;
}
};
day5 继承
最新推荐文章于 2024-10-08 20:32:22 发布