继承函数
来源:互联网 发布:淘宝买演唱会门票 编辑:程序博客网 时间:2024/06/05 17:16
#include <iostream.h>
class A
{
private:
int x1;
public:
A()
{
x1=0;
cout<<"A Constructor1"<<endl;
}
A(int i)
{
x1=i;
cout<<"A Constructor2"<<endl;
}
void disp()
{
cout<<"x1="<<x1<<endl;
}
};
class B
{
int x2;
public:
B()
{
x2=0;
cout<<"B Constructor1"<<endl;
}
B(int i)
{
x2=i;
cout<<"B Constructor2"<<endl;
}
void disp()
{
cout<<"x2="<<x2<<endl;
}
};
class C:public A
{
private:
int x3;
B b1;
public:
C()
{
x3=0;
cout<<"C Constructor1"<<endl;
}
C(int x,int y,int z):A(x),b1(y)
{
x3=z;
cout<<"C Constructor2"<<endl;
}
void disp()
{
A::disp();
b1.disp();
cout<<"X3="<<x3<<endl;
}
};
void main()
{
C c1;
c1.disp();
C c2(1,2,3);
c2.disp();
}
class A
{
private:
int x1;
public:
A()
{
x1=0;
cout<<"A Constructor1"<<endl;
}
A(int i)
{
x1=i;
cout<<"A Constructor2"<<endl;
}
void disp()
{
cout<<"x1="<<x1<<endl;
}
};
class B
{
int x2;
public:
B()
{
x2=0;
cout<<"B Constructor1"<<endl;
}
B(int i)
{
x2=i;
cout<<"B Constructor2"<<endl;
}
void disp()
{
cout<<"x2="<<x2<<endl;
}
};
class C:public A
{
private:
int x3;
B b1;
public:
C()
{
x3=0;
cout<<"C Constructor1"<<endl;
}
C(int x,int y,int z):A(x),b1(y)
{
x3=z;
cout<<"C Constructor2"<<endl;
}
void disp()
{
A::disp();
b1.disp();
cout<<"X3="<<x3<<endl;
}
};
void main()
{
C c1;
c1.disp();
C c2(1,2,3);
c2.disp();
}
- 继承函数
- 关于继承,函数的继承
- 关于继承,函数的继承
- 原型继承、构造函数继承
- 构造函数和继承
- 继承与虚函数
- 继承与虚函数
- 虚函数的继承
- 继承性函数
- 继承与虚函数
- java 继承 构造函数
- java继承-函数
- .继承、构造函数 C++
- 虚函数 虚继承
- C#构造函数继承
- JavaScript函数继承
- javaScript构造函数继承
- 虚函数及继承
- http请求头
- Open Session and Hibernate事物处理机制
- Zend Framework教程(1.11)-环境配置和库文件的引入使用
- html中select标签的常用属性
- windows系统中VMware Network Adapter VMnet1和 VMnet8的作用
- 继承函数
- java快速排序算法(数组和list两种方式)
- servlet gzip 中文乱码
- 在linux下如何判断是否已经安装某个软件?
- fckeditor上传.变_突破
- 淘宝2011.9.21校园招聘会笔试题
- Python——string之maketrans,translate函数
- Jquery多语言下拉控件,点击可实现跳转相应语言
- java读写二进制文件