// https://wokwi.com/projects/356609648316221441
class Box {
public:
static int objectCount;
Box(int unused) {
objectCount++;
}
Box() {
objectCount++;
}
int report() {
return objectCount;
}
};
int Box::objectCount = 1000;
void objectTest() {
Box Box1(7);
Box Box2(); // add an argument here use the alternate constructor, it then compiles
int wtf = Box1.report();
Serial.println(wtf);
wtf = Box2.report();
Serial.println(wtf);
return 0;
}
void setup() {
Serial.begin(115200);
Serial.println("h e l l o t h e r e !\n");
objectTest();
}
void loop() {
}
/*
classQuestion.ino: In function 'void objectTest()':
classQuestion.ino:28:14: error: request for member 'report' in 'Box2', which is of non-class type 'Box()'
wtf = Box2.report();
^~~~~~
Error during build: exit status 1
*/