Tag Archives: virtual functions

Virtual Methods and Multiple Inheritance

Previously, we covered the basics behind virtual methods. If you aren’t wholly comfortable with the subject yet, I’d recommend you go check that post out first. But if you are comfortable, we’re going to delve into the wacky fun world … Continue reading

Posted in C/C++ | Tagged , | 5 Comments

Virtual Methods

Virtual functions are a fairly well-understood programming construct in terms of how and when to use them. But have you ever stopped to think about how they actually work under the hood? You’ve probably heard the term “vtable” thrown around … Continue reading

Posted in C/C++ | Tagged , | 7 Comments

Contextual Keywords

I believe the C++ standards committee got some things wrong in the distant past. Converting constructors work implicitly with an assignment operation, function hiding and overriding are not explicit, there’s no way to prevent a subclass from providing further overrides … Continue reading

Posted in C/C++ | Tagged , , | 2 Comments

What I Learned Today About Virtual Functions

What is wrong with the following class declarations? It turns out that the correct definition is the one to Bar, which came as a surprise to me.

Posted in C/C++ | Tagged | 2 Comments

Static Polymorphism in C++

One of my coworkers recently asked me to help him solve a problem he was having in code. He had a base class with several derived classes, and he wanted to add a static method to the base class, but … Continue reading

Posted in C/C++ | Tagged , | 23 Comments

When Virtual Functions Aren’t Virtual

Let’s take a look at some innocuous-looking code and see if you can spot the bugs. If you can, you’re doing great!

Posted in C/C++ | Tagged | Leave a comment