File tree Expand file tree Collapse file tree 4 files changed +55
-22
lines changed Expand file tree Collapse file tree 4 files changed +55
-22
lines changed Original file line number Diff line number Diff line change 19
19
</ProjectConfiguration >
20
20
</ItemGroup >
21
21
<ItemGroup >
22
+ <ClCompile Include =" Log.cpp" />
22
23
<ClCompile Include =" src\Main.cpp" />
23
24
<ClCompile Include =" src\Static.cpp" />
24
25
</ItemGroup >
Original file line number Diff line number Diff line change 21
21
<ClCompile Include =" src\Static.cpp" >
22
22
<Filter >Fichiers sources</Filter >
23
23
</ClCompile >
24
+ <ClCompile Include =" Log.cpp" >
25
+ <Filter >Fichiers sources</Filter >
26
+ </ClCompile >
24
27
</ItemGroup >
25
28
</Project >
Original file line number Diff line number Diff line change
1
+ #include < iostream>
2
+
3
+ class Log
4
+ {
5
+ public:
6
+ enum Level
7
+ {
8
+ LevelError = 0 ,
9
+ LevelWarning,
10
+ LevelInfo
11
+ };
12
+
13
+ private:
14
+ Level m_LogLevel = LevelInfo;
15
+
16
+ public:
17
+ void SetLevel (Level level)
18
+ {
19
+ m_LogLevel = level;
20
+ }
21
+
22
+ void Error (const char * message)
23
+ {
24
+ if (m_LogLevel >= LevelError)
25
+ std::cout << " [ERROR]:" << message << std::endl;
26
+ }
27
+
28
+ void Warn (const char * message)
29
+ {
30
+ if (m_LogLevel >= LevelWarning)
31
+ std::cout << " [WARNING]:" << message << std::endl;
32
+ }
33
+
34
+ void Info (const char * message)
35
+ {
36
+ if (m_LogLevel >= LevelInfo)
37
+ std::cout << " [INFO]:" << message << std::endl;
38
+ }
39
+ };
40
+
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
+ }
Original file line number Diff line number Diff line change 1
1
#include < iostream>
2
2
3
- struct Entity
3
+ enum Example : char
4
4
{
5
- static int x, y;
6
-
7
- static void Print ()
8
- {
9
- std::cout << x << " , " << y << std::endl;
10
- }
5
+ A, B, C
11
6
};
12
7
13
- int Entity::x;
14
- int Entity::y;
15
-
16
- int main ()
17
- {
18
- Entity::x = 2 ;
19
- Entity::y = 3 ;
20
-
21
- Entity::x = 5 ;
22
- Entity::y = 8 ;
23
-
24
- Entity::Print ();
25
- Entity::Print ();
26
- std::cin.get ();
27
- }
You can’t perform that action at this time.
0 commit comments