Wednesday, October 2, 2013

Base pointer, pointing to a derived class with no virtual members!

I was teaching Virtual Methods in my C++ class today, one of my students sent me this in response to what was taught in class.
I think its funny; take a look:

1 comment:

ameliabrooke said...

That's a clever observation from your student! It's true that in C++, base pointers pointing to derived classes with no virtual members won't be able to access any unique functionality of the derived class. However, this scenario serves as a reminder of the importance of utilizing virtual methods when appropriate to enable polymorphism.

On a related note, if you're looking for a practical application of programming concepts, you might consider introducing your students to TurboTax. It's a popular tax preparation software that employs various programming techniques, including inheritance and polymorphism, to handle different tax scenarios. Exploring real-world examples like this can help students connect theory with practical applications and enhance their understanding of programming concepts.