1
class CA
2
{
3
public:
4
CA(int b);
5
private:
6
int m_a;
7
int m_b;
8
};
9
CA::CA(int b) : m_a(1),m_b(b)
10
{}
11
12
class CB : public CA
13
{
14
public:
15
CB(int c);
16
private:
17
int m_c;
18
};
19
CB::CB(int c) : CA(c-1), m_c(c)
20
{}
21
22
void main()
23
{
24
CB cb(3);
25
}
26
/*
27
cb.m_a = 1;
28
cb.m_b = 2;
29
cb.m_c = 3;
30
*/
class CA2
{3
public:4
CA(int b);5
private:6
int m_a;7
int m_b;8
};9
CA::CA(int b) : m_a(1),m_b(b)10
{}11

12
class CB : public CA13
{14
public:15
CB(int c);16
private:17
int m_c;18
};19
CB::CB(int c) : CA(c-1), m_c(c)20
{}21

22
void main()23
{24
CB cb(3);25
}26
/*27
cb.m_a = 1;28
cb.m_b = 2;29
cb.m_c = 3;30
*/


浙公网安备 33010602011771号