Open
Description
Hi. When we try to use singleton, inherit and customized constructor at the same time this problem will occur. Please see the following example.
You can comment the customized constructor to eliminate this problem
OS: Tested on Windows and Mac.
Arduino IDE: Version 1.6.13.
Arduino 101 Board Manager: Version 1.0.7.
Firmware updated.
class test1
{
public:
test1(){}; // You can comment this line to eliminate this runtime problem
virtual void execute();
};
class test2 :public test1
{
public:
// test2(){}; // You can comment this line to eliminate this runtime problem
void execute();
static test2* instance();
};
test2* test2::instance()
{
static test2 state;
return &state;
}
void test2::execute()
{
Serial.println("hello");
}
test2 *mytest = NULL;
void setup() {
Serial.begin(115200);
while(!Serial);
mytest = test2::instance();
Serial.println("test begin");
}
void loop() {
mytest->execute();
delay(100);
}