⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 7_11.cpp

📁 c++书籍的源代码
💻 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 + -