-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Expand file tree
/
Copy pathclass.cpp
More file actions
120 lines (92 loc) · 1.57 KB
/
class.cpp
File metadata and controls
120 lines (92 loc) · 1.57 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
class myClass
{
public:
myClass() {};
~myClass() {};
};
class myIntContainer
{
public:
myIntContainer() : val(0) {};
myIntContainer(int _val) : val(_val) {};
~myIntContainer() {};
void myMethod(myClass &mc) {};
private:
int val;
};
template <class T>
class myTContainer
{
public:
myTContainer(T _val) : val(_val) {};
~myTContainer() {};
void myMethod(myClass &mc) {};
private:
T val;
};
myIntContainer mic(10);
myTContainer<char> mtc_c('a');
class myContainerContainer : myClass
{
public:
myContainerContainer() {};
~myContainerContainer() {};
private:
myClass mc;
};
class implicitDestructorClass
{
public:
myClass mc;
implicitDestructorClass() {};
};
class implicitDestructorClass2
{
public:
implicitDestructorClass idc;
implicitDestructorClass2() {};
};
void myNewFunction()
{
myClass *mc;
mc = new myClass();
delete mc;
}
class Number {
public:
Number(int _num) : num(_num) {};
Number operator/(const Number &other) {
Number result(num / other.num);
return result;
}
private:
int num;
};
Number Calc(int num)
{
Number result(0);
return result / (Number)num;
}
typedef wchar_t *string_type;
#define STR(x) L##x
class StringContainer
{
public:
StringContainer(const string_type &str) {
// ...
}
};
StringContainer getAString() {
return StringContainer(STR("Hello, world!"));
}
class myClassWithConstructorParams
{
public:
myClassWithConstructorParams(int x, int y);
};
void testConstructors(int a, int b)
{
myClassWithConstructorParams mcwcp(a, b);
myClassWithConstructorParams *ptr;
ptr = new myClassWithConstructorParams(a, b);
}