Roger Parkinson
Active member
Has anyone tried overiding inherited virtual functions on the Teensy3?
This is my code:
The output I hope to see is "GraphicTest::init()", instead I see "App::init()", which is what I'd expect if they were not virtual functions.
Sorry if this is a dumb question. I used to know this stuff but I've been away from C++ for about a decade. I did look at some tutorials though.
Thanks for any help.
This is my code:
Code:
class App {
public:
virtual ~App() {};
virtual void init() { Serial.println("App::init()"); };
App() {};
};
...
class GraphicTest : public App {
public:
GraphicTest() :App() {};
virtual void init() { Serial.println("GraphicTest::init()"); };
virtual ~GraphicTest() {};
};
...
App app = GraphicTest();
app.init();
Sorry if this is a dumb question. I used to know this stuff but I've been away from C++ for about a decade. I did look at some tutorials though.
Thanks for any help.