質問編集履歴
2
追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -173,6 +173,6 @@
|
|
173
173
|
|
174
174
|
### 補足情報(FW/ツールのバージョンなど)
|
175
175
|
|
176
|
-
C/C++のクラスは生まれて初めて書きました。
|
176
|
+
C/C++のクラスは生まれて初めて書きました。つっこみ満載かと思われますが、ご指摘頂けると助かります。
|
177
177
|
|
178
178
|
何卒よろしくお願いいたします。
|
1
関数の中にクラスを書いてしまっていたので訂正
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,16 +8,28 @@
|
|
8
8
|
### 発生している問題・エラーメッセージ
|
9
9
|
|
10
10
|
```
|
11
|
-
|
11
|
+
classes:16:1: error: 'm' does not name a type
|
12
12
|
|
13
|
-
|
13
|
+
m.x = 10;
|
14
14
|
|
15
|
-
|
15
|
+
^
|
16
16
|
|
17
|
-
|
17
|
+
classes:17:1: error: 'm' does not name a type
|
18
18
|
|
19
|
-
|
19
|
+
m.y = 20;
|
20
20
|
|
21
|
+
^
|
22
|
+
|
23
|
+
classes:18:1: error: 'm' does not name a type
|
24
|
+
|
25
|
+
m.go(10, 20);
|
26
|
+
|
27
|
+
^
|
28
|
+
|
29
|
+
c:\Users\a\Dropbox\!Arduino\class\classes.ino: In function 'void setup()':
|
30
|
+
|
31
|
+
classes:23:48: error: no matching function for call to 'HardwareSerial::println(const char [17], int&, int&)'
|
32
|
+
|
21
33
|
Serial.println("x is %d, y is %d", m.x, m.y);
|
22
34
|
|
23
35
|
^
|
@@ -123,46 +135,34 @@
|
|
123
135
|
size_t println(void);
|
124
136
|
|
125
137
|
^~~~~~~
|
138
|
+
```
|
126
139
|
|
127
|
-
|
140
|
+
### 該当のソースコード
|
128
141
|
|
142
|
+
```Arduino
|
143
|
+
class Move
|
144
|
+
{
|
145
|
+
public:
|
146
|
+
int x;
|
147
|
+
int y;
|
129
|
-
|
148
|
+
void go(int w, int h);
|
149
|
+
};
|
130
150
|
|
131
|
-
|
151
|
+
void Move::go(int w, int h)
|
152
|
+
{
|
153
|
+
x += w;
|
154
|
+
y += h;
|
155
|
+
}
|
132
156
|
|
157
|
+
Move m;
|
158
|
+
m.x = 10;
|
159
|
+
m.y = 20;
|
133
|
-
|
160
|
+
m.go(10, 20);
|
134
161
|
|
135
|
-
^~
|
136
|
-
```
|
137
|
-
|
138
|
-
### 該当のソースコード
|
139
|
-
|
140
|
-
```Arduino
|
141
162
|
void setup()
|
142
163
|
{
|
143
|
-
class Move
|
144
|
-
{
|
145
|
-
public:
|
146
|
-
int x;
|
147
|
-
int y;
|
148
|
-
void go(int w, int h);
|
149
|
-
};
|
150
|
-
|
151
|
-
void Move::go(int w, int h)
|
152
|
-
{
|
153
|
-
x += w;
|
154
|
-
y += h;
|
155
|
-
}
|
156
|
-
|
157
|
-
Move m;
|
158
|
-
m.x = 10;
|
159
|
-
m.y = 20;
|
160
|
-
m.go(10, 20);
|
161
164
|
Serial.begin(9600);
|
162
|
-
Serial.println("x is %d, y is %d", m.x, m.y);
|
165
|
+
Serial.println("x is %d, y is %d", m.x, m.y);
|
163
|
-
|
164
|
-
|
165
|
-
|
166
166
|
}
|
167
167
|
|
168
168
|
void loop()
|