Skip to content

Commit ec553c7

Browse files
committed
Add Constructors in C++
1 parent 99c2d25 commit ec553c7

File tree

2 files changed

+35
-11
lines changed

2 files changed

+35
-11
lines changed

HelloWorld/Log.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ class Log
3838
}
3939
};
4040

41-
int main()
42-
{
43-
Log log;
44-
log.SetLevel(Log::LevelError);
45-
log.Warn("Hello!");
46-
log.Error("Hello!");
47-
log.Info("Hello!");
48-
std::cin.get();
49-
}
41+
//int main()
42+
//{
43+
// Log log;
44+
// log.SetLevel(Log::LevelError);
45+
// log.Warn("Hello!");
46+
// log.Error("Hello!");
47+
// log.Info("Hello!");
48+
// std::cin.get();
49+
//}

HelloWorld/src/Main.cpp

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,31 @@
11
#include <iostream>
22

3-
enum Example : char
3+
class Entity
44
{
5-
A, B, C
5+
public:
6+
float X, Y;
7+
8+
Entity()
9+
{
10+
X = 0.0f;
11+
Y = 0.0f;
12+
}
13+
14+
Entity(float x, float y)
15+
{
16+
X = x;
17+
Y = y;
18+
}
19+
20+
void Print()
21+
{
22+
std::cout << X << ", " << Y << std::endl;
23+
}
624
};
725

26+
int main()
27+
{
28+
Entity e(10.0f, 5.0f);
29+
e.Print();
30+
std::cin.get();
31+
}

0 commit comments

Comments
 (0)