So, if I have
class base { public: virtual void start(); virtual void stop(); void doSomething() { start(); .... stop(); } } class derived : public base { public: void start(); void stop(); }
calling derived.doSomething() will call derived::start() and derived::stop(). BUT this only works if they're virtual.
derived.doSomething()
I wanted to know why it doesn't work without the virtual keyword, meaning the lower level details. I can't find much about this online...
virtual
Thanks!
Without the virtual keyword, base::doSomething code has NO IDEA about the derived version's of those methods (think linker resolution)
2.1m questions
2.1m answers
60 comments
57.0k users