-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses.cpp
More file actions
executable file
·67 lines (56 loc) · 1.84 KB
/
Copy pathclasses.cpp
File metadata and controls
executable file
·67 lines (56 loc) · 1.84 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
#include <array>
#include <iostream>
#include <memory>
#include "lib_usr.h"
void classes_guide() {
class CRectangle rect, rect_b;
rect.set_values(3, 4);
std::cout << "Area: " << rect.area() << std::endl;
std::cout << "get_pointer: " << rect.get_pointer() << std::endl;
std::cout << "get_pointer: " << (unsigned long int)&rect << std::endl;
std::cout << "get_pointer: " << rect_b.get_pointer() << std::endl;
std::cout << "get_pointer: " << (unsigned long int)&rect_b << std::endl;
// class CCircle foo(10.0); // functional form
// class CCircle foo = 10.0; // assignment init.
// class CCircle foo{10.0}; // uniform init.
// class CCircle foo = {10.0}; // POD-like
class CCircle fooo(10.0);
CCircle(10);
std::cout << "foo's circumference: " << fooo.circum() << '\n';
//**Poznamka
//**Funkcia sa vola so zatvorkami standardne a
//**bez zatvoriek je smernik
//**Class je standardne bez zatvoriek a preklada sa
//**do zatvorkovej formy koli konstruktoru
//**mozno preto smernik = class nefunguje s errorom
//** ze chcem priradit class do *class
void (*pp)(int);
(void)pp;
pp = CCircle;
class CRectangle obj; // obj nieje smernik!!!!!
// teda nemozem foo = obj;
obj.set_values(2, 2);
class CRectangle *foo, *bar, *baz = new CRectangle[2];
(void)bar;
foo = &obj;
(*foo).set_values(3, 3);
foo->set_values(3, 3);
baz[0].set_values(4, 4);
baz[1].set_values(4, 4);
// overloading operators
CVector a_vect(5, 5);
CVector b_vect(5, 5);
CVector result;
result = a_vect - b_vect;
std::cout << "a_vect + b_vect = (" << result.x << "," << result.y << ")"
<< std::endl;
CMy_int a;
CMy_int b;
CMy_int res;
res = a + b;
// ako vypisat res.n len ako res
// pertazit operator <<
//
std::cout << "a + b = (" << res.n << "," << res.n << ")" << std::endl;
// end
};