Friday, July 16, 2010

Overriding vs. Overloading

Some excerpts from Dan Saks' article from C++ User's Journal February 1994 Overloading means declaring the same symbol in the same scope to represent two or more different entities. Overriding means redefining a name in a derived class to hide a name inherited from a base class. Overriding is all about parent-child relationship, it is not just about virtual functions. For a given class the translator creates an entry in the vtbl only for each virtual function in the class, not for the non-virtual functions. A derived class can override any of its inherited functions, be they virtual or not. You can't turn off the dynamic binding when you override a virtual function. The translator creates an image for child's vtbl by coping the parent's vtbl, when it parses a declaration in child that overrides a virtual function the translator simply overwrites teh entry for that function in child's vtbl.

No comments:

Post a Comment