Scoped Enumerations

In C++03, enumerations are declared as follows: enum Suit { Hearts, Diamonds, Clubs, Spades }; Suit suit = Hearts; As can be seen, Hearts is in the global namespace. This could give rise to potential name collisions with other enums. Another issue is that it is difficult to find instances of a particular enum via … Read more

Overriding Functions

The C++03 way In C++03, the virtual keyword is used to implement function overloading, as shown in the example below: class Shape { public: virtual bool isCircle() { return false; } }; class Circle : public Shape { virtual bool isCircle() { return true; } }; We can test this code as follows: bool test() … Read more