質問編集履歴
7
文章の訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,7 +14,6 @@
|
|
14
14
|
●main.cpp
|
15
15
|
```
|
16
16
|
#include <iostream>
|
17
|
-
|
18
17
|
#include "counter.h"
|
19
18
|
|
20
19
|
using namespace std;
|
@@ -34,7 +33,6 @@
|
|
34
33
|
//下記の文、c1.getCount() + c2.getCount()を staticメンバ関数( getTotalCount() )によって出力できるようにしたい。
|
35
34
|
cout << "トータルのカウント数:" << c1.getCount() + c2.getCount() << endl;
|
36
35
|
|
37
|
-
|
38
36
|
return 0;
|
39
37
|
}
|
40
38
|
```
|
@@ -43,12 +41,11 @@
|
|
43
41
|
```
|
44
42
|
#ifndef _COUNTER_H_
|
45
43
|
#define _COUNTER_H_
|
46
|
-
|
44
|
+
|
47
45
|
class Counter{
|
48
46
|
private:
|
49
47
|
// 回数
|
50
48
|
int m_count;
|
51
|
-
staic int m_totalCount;
|
52
49
|
public:
|
53
50
|
// コンストラクタ
|
54
51
|
Counter();
|
@@ -58,17 +55,15 @@
|
|
58
55
|
void count();
|
59
56
|
// カウントの数
|
60
57
|
int getCount();
|
61
|
-
|
62
58
|
};
|
63
|
-
|
59
|
+
|
64
60
|
#endif // _COUNTER_H_
|
65
61
|
```
|
66
62
|
|
67
63
|
●counter.cpp
|
68
64
|
```
|
69
|
-
|
70
65
|
#include "counter.h"
|
71
|
-
|
66
|
+
|
72
67
|
// コンストラクタ(カウント回数を0で初期化)
|
73
68
|
Counter::Counter() : m_count(0)
|
74
69
|
{
|
@@ -82,7 +77,6 @@
|
|
82
77
|
int Counter::getCount(){
|
83
78
|
return m_count;
|
84
79
|
}
|
85
|
-
|
86
80
|
```
|
87
81
|
|
88
82
|
実行結果
|
6
文章の訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -83,4 +83,9 @@
|
|
83
83
|
return m_count;
|
84
84
|
}
|
85
85
|
|
86
|
-
```
|
86
|
+
```
|
87
|
+
|
88
|
+
実行結果
|
89
|
+
c1のカウント数:3
|
90
|
+
c2のカウント数:1
|
91
|
+
トータルのカウント数:4
|
5
文章の訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -32,7 +32,7 @@
|
|
32
32
|
cout << "c2のカウント数:" << c2.getCount() << endl;
|
33
33
|
|
34
34
|
//下記の文、c1.getCount() + c2.getCount()を staticメンバ関数( getTotalCount() )によって出力できるようにしたい。
|
35
|
-
|
35
|
+
cout << "トータルのカウント数:" << c1.getCount() + c2.getCount() << endl;
|
36
36
|
|
37
37
|
|
38
38
|
return 0;
|
4
文章の訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -59,8 +59,6 @@
|
|
59
59
|
// カウントの数
|
60
60
|
int getCount();
|
61
61
|
|
62
|
-
//static int getTotalCount(int a,int b);
|
63
|
-
|
64
62
|
};
|
65
63
|
|
66
64
|
#endif // _COUNTER_H_
|
@@ -85,9 +83,4 @@
|
|
85
83
|
return m_count;
|
86
84
|
}
|
87
85
|
|
88
|
-
//static int Counter::getTotalCount(int a, int b)
|
89
|
-
{
|
90
|
-
//m_totalCount
|
91
|
-
return a + b;
|
92
|
-
}
|
93
86
|
```
|
3
コメントの修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -31,7 +31,7 @@
|
|
31
31
|
cout << "c1のカウント数:" << c1.getCount() << endl;
|
32
32
|
cout << "c2のカウント数:" << c2.getCount() << endl;
|
33
33
|
|
34
|
-
//下記の文、c1.getCount() + c2.getCount()を
|
34
|
+
//下記の文、c1.getCount() + c2.getCount()を staticメンバ関数( getTotalCount() )によって出力できるようにしたい。
|
35
35
|
// cout << "トータルのカウント数:" << c1.getCount() + c2.getCount() << endl;
|
36
36
|
|
37
37
|
|
2
タイトルの修正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
現在のコードを
|
1
|
+
現在のコードを staticメンバ関数によって出力できるようにしたいです。
|
body
CHANGED
File without changes
|
1
文章の訂正
title
CHANGED
@@ -1,1 +1,1 @@
|
|
1
|
-
現在のコードを静的
|
1
|
+
現在のコードを静的関数によって出力できるようにしたいです。
|
body
CHANGED
@@ -31,10 +31,10 @@
|
|
31
31
|
cout << "c1のカウント数:" << c1.getCount() << endl;
|
32
32
|
cout << "c2のカウント数:" << c2.getCount() << endl;
|
33
33
|
|
34
|
-
//下記の文、c1.getCount() + c2.getCount()を静的メソッドによって出力できるようにしたい。
|
34
|
+
//下記の文、c1.getCount() + c2.getCount()を静的メソッド( getTotalCount() )によって出力できるようにしたい。
|
35
35
|
// cout << "トータルのカウント数:" << c1.getCount() + c2.getCount() << endl;
|
36
|
-
cout << "トータルのカウント数:" << Counter::getTotalCount(c1.getCount ,c2.getCount ) << endl;
|
37
36
|
|
37
|
+
|
38
38
|
return 0;
|
39
39
|
}
|
40
40
|
```
|
@@ -59,7 +59,7 @@
|
|
59
59
|
// カウントの数
|
60
60
|
int getCount();
|
61
61
|
|
62
|
-
//static int getTotalCount(
|
62
|
+
//static int getTotalCount(int a,int b);
|
63
63
|
|
64
64
|
};
|
65
65
|
|
@@ -85,8 +85,7 @@
|
|
85
85
|
return m_count;
|
86
86
|
}
|
87
87
|
|
88
|
-
//
|
88
|
+
//static int Counter::getTotalCount(int a, int b)
|
89
|
-
static int Counter::getTotalCount(getCount a, getCount b)
|
90
89
|
{
|
91
90
|
//m_totalCount
|
92
91
|
return a + b;
|