質問編集履歴
2
追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -348,7 +348,7 @@
|
|
348
348
|
|
349
349
|
|
350
350
|
|
351
|
-
C/C++のクラスは生まれて初めて書きました。
|
351
|
+
C/C++のクラスは生まれて初めて書きました。つっこみ満載かと思われますが、ご指摘頂けると助かります。
|
352
352
|
|
353
353
|
|
354
354
|
|
1
関数の中にクラスを書いてしまっていたので訂正
test
CHANGED
File without changes
|
test
CHANGED
@@ -18,23 +18,47 @@
|
|
18
18
|
|
19
19
|
```
|
20
20
|
|
21
|
+
classes:16:1: error: 'm' does not name a type
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
m.x = 10;
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
^
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
classes:17:1: error: 'm' does not name a type
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
m.y = 20;
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
^
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
classes:18:1: error: 'm' does not name a type
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
m.go(10, 20);
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
^
|
54
|
+
|
55
|
+
|
56
|
+
|
21
57
|
c:\Users\a\Dropbox\!Arduino\class\classes.ino: In function 'void setup()':
|
22
58
|
|
23
59
|
|
24
60
|
|
25
|
-
classes:11:18: error: qualified-id in declaration before '(' token
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
void Move::go(int w, int h)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
^
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
classes:2
|
61
|
+
classes:23:48: error: no matching function for call to 'HardwareSerial::println(const char [17], int&, int&)'
|
38
62
|
|
39
63
|
|
40
64
|
|
@@ -248,26 +272,6 @@
|
|
248
272
|
|
249
273
|
^~~~~~~
|
250
274
|
|
251
|
-
|
252
|
-
|
253
|
-
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:88:12: note: candidate expects 0 arguments, 3 provided
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
c:\Users\a\Dropbox\!Arduino\class\classes.ino: At global scope:
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
c:\Users\a\Dropbox\!Arduino\class\classes.ino:8:14: warning: 'void setup()::Move::go(int, int)' used but never defined
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
void go(int w, int h);
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
^~
|
270
|
-
|
271
275
|
```
|
272
276
|
|
273
277
|
|
@@ -278,68 +282,64 @@
|
|
278
282
|
|
279
283
|
```Arduino
|
280
284
|
|
285
|
+
class Move
|
286
|
+
|
287
|
+
{
|
288
|
+
|
289
|
+
public:
|
290
|
+
|
291
|
+
int x;
|
292
|
+
|
293
|
+
int y;
|
294
|
+
|
295
|
+
void go(int w, int h);
|
296
|
+
|
297
|
+
};
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
void Move::go(int w, int h)
|
302
|
+
|
303
|
+
{
|
304
|
+
|
305
|
+
x += w;
|
306
|
+
|
307
|
+
y += h;
|
308
|
+
|
309
|
+
}
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
Move m;
|
314
|
+
|
315
|
+
m.x = 10;
|
316
|
+
|
317
|
+
m.y = 20;
|
318
|
+
|
319
|
+
m.go(10, 20);
|
320
|
+
|
321
|
+
|
322
|
+
|
281
323
|
void setup()
|
282
324
|
|
283
325
|
{
|
284
326
|
|
327
|
+
Serial.begin(9600);
|
328
|
+
|
329
|
+
Serial.println("x is %d, y is %d", m.x, m.y);
|
330
|
+
|
331
|
+
}
|
332
|
+
|
333
|
+
|
334
|
+
|
285
|
-
|
335
|
+
void loop()
|
286
|
-
|
336
|
+
|
287
|
-
|
337
|
+
{
|
288
|
-
|
289
|
-
public:
|
290
|
-
|
291
|
-
int x;
|
292
|
-
|
293
|
-
int y;
|
294
|
-
|
295
|
-
void go(int w, int h);
|
296
|
-
|
297
|
-
};
|
298
338
|
|
299
339
|
|
300
340
|
|
301
|
-
void Move::go(int w, int h)
|
302
|
-
|
303
|
-
{
|
304
|
-
|
305
|
-
x += w;
|
306
|
-
|
307
|
-
y += h;
|
308
|
-
|
309
|
-
}
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
Move m;
|
314
|
-
|
315
|
-
m.x = 10;
|
316
|
-
|
317
|
-
m.y = 20;
|
318
|
-
|
319
|
-
m.go(10, 20);
|
320
|
-
|
321
|
-
Serial.begin(9600);
|
322
|
-
|
323
|
-
Serial.println("x is %d, y is %d", m.x, m.y);
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
341
|
}
|
332
342
|
|
333
|
-
|
334
|
-
|
335
|
-
void loop()
|
336
|
-
|
337
|
-
{
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
}
|
342
|
-
|
343
343
|
```
|
344
344
|
|
345
345
|
|