C++ Overloading, overriding and hiding, oh my!

Continuing where I left off previously, I’ve been going through chapter 9, Inheritance and Polymorphism from Ivor Horton’s Beginning Visual C++ 2008 and consulting various other books a little more often than I had been up until now. One of those books was C++ Programming: Visual QuickStart Guide, by Larry Ullman and Andreas Signer.

Edit: There is a slightly better (cleaned up) version here.

I was reading chapter 8, Class Inheritance where I ran afoul of this warning:

Pay attention when overriding methods. If you don’t use the exactly same parameters and return values, you’ll end up with an overloaded method, and not an overridden one. Such mistakes are very hard to debug

Continue reading

Why a base class pointer to a derived class object is ok

As I’ve mentioned in previous posts, I’ve been going through Ivor Horton’s Beginning Visual C++ 2008 and thanks to the good folks at cprogramming.com, I’ve been steered back on course by numerous helpful posts while working through chapter exercises.

For a few weeks now, I’ve been in chapter 9, Inheritance and Polymorphism, and have been extensively taking notes. At one point I veered off course long enough to purchase or checkout from the library several other books, several of which I explored and ended up learning about Inheritance and Polymorphism; so much for a sabbatical!

Continue reading