?? 7_11.cpp
字號:
#include<iostream.h>
class A
{
public:
A(int x);
protected:
int a;
};
A::A(int x)
{
a=x;
}
class B:virtual public A
{
public:
B(int x,int y);
protected:
int b;
};
B::B(int x,int y):A(x)
{
b=y;
}
class C:virtual public A
{
public:
C(int x,int y);
protected:
int c;
};
C::C(int x,int y):A(x)
{
c=y;
}
class D:public B,public C
{
public:
D(int w,int x,int y,int z);
void display(void);
private:
int a;
};
D::D(int w,int x,int y,int z):A(w),B(w,x),C(w,y)
{
a=z;
}
void D::display(void)
{
cout<<"A::a="<<A::a<<endl;
cout<<"a="<<a<<" b="<<b<<" c="<<c<<endl;
}
int main()
{
D s(1,2,3,4);
s.display();
return(0);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -