-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlib_usr.cpp
More file actions
executable file
·155 lines (137 loc) · 2.74 KB
/
Copy pathlib_usr.cpp
File metadata and controls
executable file
·155 lines (137 loc) · 2.74 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#include "lib_usr.h"
#include <iostream>
/*
class hodnoty *test_return_pointer_bad(void) {
class hodnoty result;
result.a = 10;
result.b = 20;
return (&result);
}
*/
/*
//!!!!!!!!!!!JESUS sice vrati smernik ale pamat uz nieje vyhradena a teda sa
moze lubovolne zmenit!!!!!
*/
/*
Factory - vyrabam kopie na inych adresach vdaka "new"
*/
class hodnoty *test_return_pointer(void) {
class hodnoty *result = new hodnoty;
result->a = 10;
result->b = 20;
return (result);
}
/*
Erasor hodnoty, schopny handlovat aj NULL pointer
*/
int test_return_pointer_erasor(class hodnoty *ptr_hodnoty) {
if (ptr_hodnoty == nullptr) {
return -1;
}
delete ptr_hodnoty;
ptr_hodnoty = nullptr;
return 0;
}
void increment_all(int *start, int *stop) {
int *current;
current = start;
while (current != stop) {
*current = *current + 1;
current++;
}
}
void print_all(const int *start, const int *stop) {
const int *current;
current = start;
while (current != stop) {
std::cout << *current << std::endl;
current++;
}
}
void print_all_two(int *start, int *stop) {
int *current;
current = start;
while (current != stop) {
std::cout << *current << std::endl;
current++;
}
}
void do_nothing(int *start, int *stop) {
(void)start;
(void)stop;
}
void increase_diff_type(void *data, int psize) {
if (psize == sizeof(char)) {
/* code */
char *pchar = new char;
pchar = (char *)data;
*pchar = (*pchar) + 1;
}
if (psize == sizeof(int)) {
/* code */
int *pint = new int;
pint = (int *)data;
*pint = (*pint) + 1;
}
}
//**
// Funkcie a classy pre CLASS guide
void CRectangle::set_values(int x, int y) {
/* code */
this->width = x;
// width = x; //ekvivalent this->width = x;
height = y;
}
// this VRATI ADRESU INSTANCIE OBJEKTU
// mal by byt unikatny :-) pouzitelne ako ID objektu
unsigned long int CRectangle::get_pointer() {
/*code*/
return (unsigned long int)this;
}
CRectangle::CRectangle() {
width = 0;
height = 0;
}
CRectangle::~CRectangle() {}
int CRectangle::area(void) {
/*code*/
return width * height;
}
CCircle::CCircle(double r) {
/*code*/
radius = r;
}
CCircle::~CCircle() {}
double CCircle::circum() {
/*code*/
return 2 * radius * 3.14159265;
}
void CCircle(int a) { (void)a; }
CVector::CVector() {
x = 0;
y = 0;
};
CVector::CVector(int a, int b) {
x = a;
y = b;
}
CVector CVector::operator-(const CVector ¶m) {
CVector temp;
temp.x = x + param.x;
temp.y = y + param.y;
return temp;
}
CVector::~CVector(){};
int CVector::xyadd() { return (x + y); }
CMy_int CMy_int::operator+(const CMy_int ¶m) {
/*code*/
CMy_int temp;
temp.n = n * param.n;
return temp;
}
/*
CMy_int CMy_int::&operator=(int param) {
n = param;
return *this;
}
*/