Notice
Recent Posts
Recent Comments
Link
Typing diary
명품 c++ programming 6장 8번 본문
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
#include<iostream>
#include<string>
using namespace std;
class Trace
{
static string tag[100], log[100];
static int count;
public:
static void put(const char* t,const char* l);
static void print(const char* t = NULL);
};
string Trace::tag[100], Trace::log[100];
int Trace::count = 0;
void Trace::put(const char* t, const char* l)
{
tag[count] = t;
log[count] = l;
count++;
}
void Trace::print(const char* t)
{
if (t == NULL)
{
cout << "---모든 Trace 정보를 출력합니다.---" << endl;
for (int i = 0; i < count; i++)
{
cout << tag[i] << ":" << log[i]<<endl;
}
}
else
{
cout << t << "---태그의 Trace 정보를 출력합니다.---"<< endl;
for (int i = 0; i < count; i++)
{
if(t == tag[i])
cout << tag[i] << ":" << log[i] << endl;
}
}
}
void f()
{
int a, b, c;
cout << "두 개의 정수를 입력하세요>>";
cin >> a >> b;
Trace::put("f()", "정수를 입력 받았음");
c = a + b;
Trace::put("f()", "합 계산");
cout << "합은" << c << endl;
}
int main()
{
Trace::put("main()", "프로그램 시작합니다.");
f();
Trace::put("main()", "종료");
Trace::print("f()");
Trace::print();
}
|
cs |
d
'C, C++' 카테고리의 다른 글
c++ 연산자중복 (0) | 2022.08.16 |
---|---|
c++ static멤버 (0) | 2022.08.16 |
명품 c++ programming 7장 Open Challenge (0) | 2022.08.16 |
명품 c++ programming 4장 10번 (0) | 2022.08.16 |
c++ 참조 (0) | 2022.08.16 |