Multiple inheritance basic program in C++
#include <iostream>
using std::cout;
class b1{
int x;
public:
b1(int = 0);
int get();
};
b1::b1(int u){
x = u;
cout << "B1 constructor\n";
}
int b1::get(){
return x;
}
class b2{
int x;
public:
b2(int = 0);
int get();
};
b2::b2(int u){
x = u;
cout << "B2 constructor\n";
}
int b2::get(){
return x;
}
class a: public b1, public b2{
int x;
public:
a(int u = 0);
};
a::a(u){
x = u;
cout << "A constructor\n";
}
int main(){
a o;
reuturn 0;
}
No comments:
Post a Comment