The Artima Developer Community
Sponsored Link

Multiple Inheritance and Interfaces
A Conversation with Scott Meyers, Part I
by Bill Venners
December 16, 2002

<<  Page 3 of 4  >>

Advertisement

The Meaning of ABC Inheritance

Bill Venners: If public inheritance means ISA, what does ABC inheritance mean?

Scott Meyers: ABC inheritance still means ISA. Public inheritance always means ISA. That's just what it means. If you are inheriting from an ABC, all you are saying is, "I'm going to inherit an interface, and that particular interface can never be instantiated." But in C++ there can still be data in the ABC, and there are certainly going to be virtual member functions, so you still have behavior. Publicly inheriting from an ABC just means that every instance of my class IS AN instance of this ABC. That's what the inheritance is asserting. That's what ISA means. "I am one of those." The fact that the base class is an ABC says, "By myself, I am not complete enough to be instantiated." But those are orthogonal statements.

Bill Venners: Let's define ABC. ABC means abstract base class. So what would you call in C++ that special case of an ABC that has no data and nothing but pure virtual functions, which have no implementation.

Scott Meyers: The C++ community does not have a name for that. There is no commonly accepted term for that kind of class. Some people call it "interface class." Some people quite incorrectly call it a virtual base class, but as long as we are among friends and know what we are talking about, that's OK. But the notion of essentially a C++ implementation of an interface in Java or C# does not have a name in C++.

<<  Page 3 of 4  >>


Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us