renaming
This commit is contained in:
committed by
JamesFlare1212
parent
9096194d90
commit
21fa2c03de
35
lectures/26_inheritance_II/multiple_inheritance1.cpp
Normal file
35
lectures/26_inheritance_II/multiple_inheritance1.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <iostream>
|
||||
|
||||
class B
|
||||
{
|
||||
public:
|
||||
B(int b1):b(b1){}
|
||||
protected:
|
||||
int b;
|
||||
};
|
||||
|
||||
class C
|
||||
{
|
||||
public:
|
||||
C(int c1):c(c1){}
|
||||
protected:
|
||||
int c;
|
||||
};
|
||||
|
||||
class D: public B, public C
|
||||
{
|
||||
public:
|
||||
D(int b1, int c1):B(b1),C(c1),d(b1+c1){}
|
||||
|
||||
void print(){
|
||||
std::cout << "d is " << d << std::endl;
|
||||
}
|
||||
protected:
|
||||
int d;
|
||||
};
|
||||
|
||||
int main(){
|
||||
D* dOjbect = new D(2,3);
|
||||
dOjbect->print();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user