正如你可能从这个问题中猜到的那样,我对使用c ++的oop编程很新.(之前我只做过Java)无论如何,我正在尝试为Arduino项目创建一个自定义类并得到上面提到的错误.这是我的文件:
标头Touchable.h
#ifndef Touchable
#define Touchable
#include <Adafruit_TFTLCD.h>
#include <Arduino.h>
class Touchable {
public:
int posX;
int posY;
Touchable(int, int); //<-- Error here
~Touchable();
void Touchable::draw();
};
#endif
Run Code Online (Sandbox Code Playgroud)
和Touchable.cpp
#include "Touchable.h" //include the declaration for this class
#include <Adafruit_TFTLCD.h>
Touchable::Touchable(int x, int y) {
posX = x;
posY = y;
}
Touchable::~Touchable() {
/*nothing to destruct*/
}
//turn the LED on
void Touchable::draw() {
//tft.fillRect(posX, posY, 100, 100, 0x0000);
}
Run Code Online (Sandbox Code Playgroud)
编辑:编译器消息:
In file included from sketch/Touchable.cpp:1:0:
Touchable.h:11: error: expected …Run Code Online (Sandbox Code Playgroud)