-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_attribute.cpp
More file actions
38 lines (34 loc) · 825 Bytes
/
test_attribute.cpp
File metadata and controls
38 lines (34 loc) · 825 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
#include <iostream>
using std::cout;
using std::endl;
class Test {
friend class Test2;
int test=0; //private
public:
Test(){ cout <<"Test::Test" << endl; }
~Test(){ cout <<"Test::~Test" << endl; }
int test2;
friend void set_test(int i);
friend int get_test(void);
protected:
int test3=9;
};
class Test2: Test {
public:
Test2(){ cout <<"Test2::Test2" << endl; }
~Test2(){ cout <<"Test2::~Test2" << endl; }
void set_test(int i){ test=i; }
int get_test(void){ return test;}
void set_test3(int i){ test3=i; }
int get_test3(void){ return test3;}
};
int main()
{
Test2 test2;
test2.set_test(3);
test2.set_test3(4);
cout << "test2.get_test:" << test2.get_test();
cout << endl;
cout << "test2.get_test3:" << test2.get_test3();
cout << endl;
}