Skip to content

Commit 363883d

Browse files
committed
Add Destructors in C++
1 parent ec553c7 commit 363883d

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

HelloWorld/src/Main.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ class Entity
99
{
1010
X = 0.0f;
1111
Y = 0.0f;
12+
std::cout << "Created Entity!" << std::endl;
1213
}
1314

14-
Entity(float x, float y)
15+
~Entity()
1516
{
16-
X = x;
17-
Y = y;
17+
std::cout << "Destroyed Entity!" << std::endl;
1818
}
1919

2020
void Print()
@@ -23,9 +23,15 @@ class Entity
2323
}
2424
};
2525

26-
int main()
26+
void Function()
2727
{
28-
Entity e(10.0f, 5.0f);
28+
Entity e;
2929
e.Print();
30+
}
31+
32+
int main()
33+
{
34+
Function();
35+
3036
std::cin.get();
3137
}

0 commit comments

Comments
 (0)