-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstructors.cpp
More file actions
73 lines (56 loc) · 780 Bytes
/
constructors.cpp
File metadata and controls
73 lines (56 loc) · 780 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
class A{
int & _a;
public:
A(int & a):_a{a}{};
A(const A& rhs):_a{rhs._a}{};
A& operator=(const A& rhs){
_a = rhs._a;
return *this;
};
};
class B{
public:
int * _b;
B(int * b):_b{b}{};
};
class C{
public:
const int _c;
C(const int c):_c{c}{};
};
struct S{
const int i = 10;
S(const int _i):i{_i}{};
int add(int x){
return x+i;
}
};
class P{
private:
P() = default;
int _a;
friend class S1;
};
class S1{
public:
static void fun(){
P p;
P p1 = p;
}
};
int main(){
int x = 1;
A a(x);
B b(&x);
B b1 = b;
std::cout << *b1._b << '\n' ;
C c(10);
S s(11);
S s1 = s;
std::cout << s1.i << '\n';
auto fptr = &S::add;
std::cout << (s.*fptr)(11) << '\n';
//P p;
S1::fun();
}