7_7.cpp
来自「c++书籍的源代码」· C++ 代码 · 共 47 行
CPP
47 行
#include<iostream.h>
class A1
{
public:
A1(int x);
protected:
int a;
};
A1::A1(int x)
{
a=x;
}
class A2
{
public:
A2(int x);
protected:
int a;
};
A2::A2(int x)
{
a=x;
}
class A3:public A1,public A2
{
public:
A3(int x,int y,int z);
void display(void);
private:
int a;
};
A3::A3(int x,int y,int z):A1(x),A2(y)
{
a=z;
}
void A3::display(void)
{
cout<<"A1::a="<<A1::a<<endl;
cout<<"A2::a="<<A2::a<<endl;
cout<<"a="<<a<<endl;
}
int main()
{
A3 s(1,2,3);
s.display();
return(0);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?