-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConstructors.cpp
More file actions
64 lines (43 loc) · 776 Bytes
/
Constructors.cpp
File metadata and controls
64 lines (43 loc) · 776 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
#include <iostream>
using namespace std;
// Constructors
// Link: https://www.youtube.com/watch?v=FXhALMsHwEY
// Title: Constructors in C++
// Creator: The Cherno
//
class Entity
{
public:
float X, Y;
// Entity() = delete; // se sriviamo qusto la parte di sotto verrà cancellata
Entity() // serve per inizializazzione delle classi (questa^)
{
X = 0.0f;
Y = 0.0f;
}
Entity(float x, float y)
{
X = x;
Y = x;
}
// void Init() // non ci serve! ^^^
// {
// X = 0.0f;
// Y = 0.0f;
// }
void Print()
{
cout << X << ", " << Y << endl;
}
};
int main()
{
setlocale(LC_ALL, "italian");
Entity e(10.0f, 5.5f);
// e.Init(); // non ci seve più
// cout << e.X << endl;
e.Print();
Entity el;
el.Print();
return 0;
}