-
Notifications
You must be signed in to change notification settings - Fork 0
/
197.cpp
47 lines (41 loc) · 910 Bytes
/
197.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#include <iostream>
using namespace std;
class AbstractBase
{
public:
string baseprivate1;
virtual void set_privates() = 0;
void print() { cout << baseprivate1 << endl; }
void foo()
{
cout << "CPP Code";
}
};
class Derived : private AbstractBase
{ // use private inheritance on AbstractBase
private:
string derivedprivate1;
public:
// expose AbstractBase's methods with using-declarations
using AbstractBase::foo;
using AbstractBase::print;
void set_privates()
{
this->baseprivate1 = "Base private1";
this->derivedprivate1 = "Derived private1";
}
void print()
{
AbstractBase::print();
cout << this->derivedprivate1 << endl;
;
}
};
int main(int argc, char *argv[])
{
Derived d;
d.set_privates();
d.print();
d.foo();
return 0;
}