Can base class have the net sum of all the interfaces of its derived classes?

V

Vj

Hi all,

I am contemplating a design wherein most functions in my base
class are virtual and says "request_not_supported". My derived classes
override only the functions they support. In net effect, my base class
always has the sum of all the I/Fs of my derived classes. My friend
disagrees with me saying that derived classes are always supposed to be
"base class ++". Is there any mistake in my approach? Kindly let me
know if I'm violating any OOPS concepts.


R
V
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

Hi all,

I am contemplating a design wherein most functions in my base
class are virtual and says "request_not_supported". My derived classes
override only the functions they support. In net effect, my base class
always has the sum of all the I/Fs of my derived classes. My friend
disagrees with me saying that derived classes are always supposed to be
"base class ++". Is there any mistake in my approach? Kindly let me
know if I'm violating any OOPS concepts.

Your approach is just fine, and for some situations better than adding
more functions to the derived classes. It all depends on how you expect
to use the classes. Notice though that it might be a better idea to
make the base purely virtual so that you can't create an instance of it
if it's not going to have any meaningful usage anyway.
 
D

David Harmon

On 19 Dec 2006 05:48:15 -0800 in comp.lang.c++, "Vj"
disagrees with me saying that derived classes are always supposed to be
"base class ++". Is there any mistake in my approach? Kindly let me
know if I'm violating any OOPS concepts.

Google for "Liskov substitution principle". After reading the results
of that, please take further questions of this type to comp.object,
there is nothing C++ specific about it.
 
D

David Harmon

On 19 Dec 2006 05:48:15 -0800 in comp.lang.c++, "Vj"
disagrees with me saying that derived classes are always supposed to be
"base class ++". Is there any mistake in my approach? Kindly let me
know if I'm violating any OOPS concepts.

Google for "Liskov substitution principle", which is the common name for
your friend's argument. After reading the results of that, please take
further questions of this type to comp.object, there is nothing C++
specific about it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top