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 1919 </ProjectConfiguration >
2020 </ItemGroup >
2121 <ItemGroup >
22+ <ClCompile Include =" Log.cpp" />
2223 <ClCompile Include =" src\Main.cpp" />
2324 <ClCompile Include =" src\Static.cpp" />
2425 </ItemGroup >
Original file line number Diff line number Diff line change 2121 <ClCompile Include =" src\Static.cpp" >
2222 <Filter >Fichiers sources</Filter >
2323 </ClCompile >
24+ <ClCompile Include =" Log.cpp" >
25+ <Filter >Fichiers sources</Filter >
26+ </ClCompile >
2427 </ItemGroup >
2528</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 11#include < iostream>
22
3- struct Entity
3+ enum Example : char
44{
5- static int x, y;
6-
7- static void Print ()
8- {
9- std::cout << x << " , " << y << std::endl;
10- }
5+ A, B, C
116};
127
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