-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2018Q2.cpp
More file actions
49 lines (48 loc) · 796 Bytes
/
Copy path2018Q2.cpp
File metadata and controls
49 lines (48 loc) · 796 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
38
39
40
41
42
43
44
45
46
47
48
49
#include<iostream>
using namespace std;
class uperson
{
private:
int age;
public:
string name;
uperson()
{
cout<<"default ctor, uperson"<<endl;
}
~uperson()
{
cout<<"dtor, uperson"<<endl;
}
};
class student: private uperson
{
private:
double CGA;
public:
student()
{
cout<<"defalt ctor, student"<<endl;
}
~student()
{
cout<<"dtor, student"<<endl;
}
};
class UGstudent: public student // uperson constructor and destructor all become private and cannot be used by derived class
{
public:
UGstudent()
{
cout<<"default ctor, UG student"<<endl;
}
~UGstudent()
{
cout<<"dtor, UG student"<<endl;
}
};
int main()
{
UGstudent a;
student p=a;
}