How can I make a call from a parent class method to a child class method?
I'd expect this snippet to output "ChildClass doSomethingElse"...
/**
* Parent class
*/
class ParentClass {
public:
void doSomething();
void doSomethingElse();
};
void ParentClass::doSomething() {
this->doSomethingElse();
}
void ParentClass::doSomethingElse() {
Serial.println("ParentClass doSomethingElse");
}
/**
* Child class
*/
class ChildClass: public ParentClass{
public:
void doSomethingElse();
};
void ChildClass::doSomethingElse() {
Serial.println("ChildClass doSomethingElse");
}
// ========================================
void setup() {
Serial.begin(9600);
delay(1000);
ChildClass x = ChildClass();
x.doSomething();
}
void loop() {
}