Skip to content

Commit 1ade94e

Browse files
committed
test02.cpp
1 parent fa7eeb2 commit 1ade94e

2 files changed

Lines changed: 43 additions & 27 deletions

File tree

section1/test02.cpp

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,45 +5,39 @@
55
//
66

77
#include <iostream>
8+
#include <string>
89

9-
#define BEGIN_NAMESPACE(x) namespace x {
10-
#define END_NAMESPACE(x) }
10+
using std::string;
1111

12-
void case1()
13-
{
14-
using std::cout;
15-
using std::endl;
16-
17-
cout << "using std::xxx" << endl;
18-
}
12+
#define MAX_PATH_LEN 256
1913

20-
void case2()
21-
{
22-
using namespace std;
14+
int g_sys_flag;
2315

24-
cout << "using namespace std" << endl;
16+
namespace linux_sys {
17+
void get_rlimit_core();
2518
}
2619

27-
BEGIN_NAMESPACE(my_own)
28-
29-
class MyClass final
20+
class FilePath final
3021
{
22+
public:
23+
void set_path(const string& str);
24+
private:
25+
string m_path;
26+
int m_level;
3127
};
3228

33-
void case3()
34-
{
35-
using namespace std;
3629

37-
cout << "working in own namespace" << endl;
38-
}
39-
40-
END_NAMESPACE(my_own)
30+
// author : chrono
31+
// date : 2020-xx-xx
32+
// purpose : get inner counter value of generic T
33+
// notice : T must have xxx member
34+
// notice : return value maybe -1, means xxx, you should xxx
35+
template<typename T>
36+
int get_value(const T& v);
4137

4238
int main()
4339
{
44-
case1();
45-
case2();
40+
using namespace std;
4641

47-
my_own::case3();
48-
my_own::MyClass obj;
42+
cout << "show your code style." << endl;
4943
}

section1/test03.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@
66
//
77
// g++ test03.cpp -DNDEBUG -std=c++11 -o a.out;./a.out
88
//
9+
// show all predefined macro:
910
// gcc -E -dM - < /dev/null
1011

1112
#include <iostream>
1213

14+
#define BEGIN_NAMESPACE(x) namespace x {
15+
#define END_NAMESPACE(x) }
16+
1317
void case1()
1418
{
1519
using namespace std;
@@ -51,7 +55,25 @@ void case1()
5155

5256
}
5357

58+
BEGIN_NAMESPACE(my_own)
59+
60+
class MyClass final
61+
{
62+
};
63+
64+
void case3()
65+
{
66+
using namespace std;
67+
68+
cout << "working in own namespace" << endl;
69+
}
70+
71+
END_NAMESPACE(my_own)
72+
5473
int main()
5574
{
5675
case1();
76+
77+
my_own::case3();
78+
my_own::MyClass obj;
5779
}

0 commit comments

Comments
 (0)