privinh.cpp
280 Bytes
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
class A
{
public:
int a;
};
class B: public A
{
public:
int b;
};
class C: private A
{
public:
int c;
void fun()
{
a = 15;
};
};
int main()
{
A a;
B b;
C c;
a.a = 17;
b.a = 17;
//c.a = 17;
A* aptr = &b;
A* aptr2 = &c;
aptr2->a = 17;
}