+ 2

C++ Tutorial, Inheritance & Polymorphism

Unless I missed it, the C++ tutorial omits an important aspect of using polymorphic classes: the base destructor should be declared virtual if it's public. Otherwise deleting a derived class object via a pointer to base leads to Undefined Behaviour. And dynamic memory was introduced already in previous lessons. For details see this article by Herb Sutter (known C++ expert and member of the C++ standard committee): http://www.gotw.ca/publications/mill18.htm

22nd Nov 2018, 4:04 PM
Murzinio
Murzinio - avatar
4 Answers
+ 7
Murzinio You can pass this suggestion to SoloLearn by sending an e-mail to them (info@sololearn.com). Writing this in the Q&A forum is not as effective, and threads may drown in time, as there are many incoming questions everyday, they can't keep a lookout all the time. By sending them e-mail you may have better, direct response, when and whether or not they have time to look at it, is of course at their discretion. Regards,
23rd Nov 2018, 1:24 PM
Ipang
+ 3
Unless I am not understanding your post properly but sololearn does have a module for Inheritance & Polymorphism it is in module 7 within c++ tutorial. They teach you about derived class constructor and destructor, virtual functions, and even abstract classes. along with few other things that has to with Inheritance and Polymorphism.
22nd Nov 2018, 8:20 PM
Daen Rowe
Daen Rowe - avatar
+ 2
You're misunderstanding me, I'm talking about virtual destructors for base classes, not virtual functions in general, or even order of calling destructors. Just see the link I posted.
23rd Nov 2018, 11:38 AM
Murzinio
Murzinio - avatar
+ 1
Murzinio my apologies
23rd Nov 2018, 4:32 PM
Daen Rowe
Daen Rowe - avatar