473,626 Members | 3,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Vj
Hi all,

I am contemplating a design wherein most functions in my base
class are virtual and says "request_not_su pported". 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

Dec 19 '06 #1
4 1189
On Dec 19, 2:48 pm, "Vj" <vijay.rajamani c...@gmail.comw rote:
Hi all,

I am contemplating a design wherein most functions in my base
class are virtual and says "request_not_su pported". 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.

--
Erik Wikström

Dec 19 '06 #2
* Vj:
[off-topic, trolling]
Please disappear.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Dec 19 '06 #3
On 19 Dec 2006 05:48:15 -0800 in comp.lang.c++, "Vj"
<vi************ ****@gmail.comw rote,
>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.

Dec 19 '06 #4
On 19 Dec 2006 05:48:15 -0800 in comp.lang.c++, "Vj"
<vi************ ****@gmail.comw rote,
>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.

Dec 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2826
by: Paul | last post by:
In real life situation, do we ever come across a situation where we would need two base objects in an object. A snippet is worth 1000 words (: so... class Base { }; class Derived1:public Base { };
10
3316
by: Bhan | last post by:
Using Ptr of derived class to point to base class and viceversa class base { .... } class derived : public base { .... }
4
1506
by: Rachel Devons | last post by:
All, I'm struggling with an OOP concept. Let me try to define what I'm wanting by using some classic examples. Let's say that I have classes called Square & Circle that derive from class Shape. Within class Shape, it has a method called Save to save the object to disk. It's defined in Shape because the logic to save the shapes is uniform across all shapes. Furthermore, let's say I've defined an interface called IDraw that includes
2
1776
by: Oenone | last post by:
I could use a little advice to help prevent me making a possible mess of a project. :) In VB6, I once created a project that exposed a public interface class. I then Implemented this in various plug-in DLLs so that I could early-bind to the plug-ins by declaring objects of the interface class type. This worked fine, until one day I found that I needed to add a new method to the interface class. Of course, everything broke immediately...
9
5190
by: Sean Kirkpatrick | last post by:
To my eye, there doesn't seem to be a whole lot of difference between the two of them from a functional point of view. Can someone give me a good explanation of why one vs the other? Sean
1
2223
by: D Witherspoon | last post by:
Coming up with a scenario here. For example there is the standard .NET MailMessage class. I am creating a project (let's call it CommonBase) that has the following 2 classes EmailMessage_Base ( inherits System.Net.Mail.MailMessage and provides additional methods and properties) EmailMessage_Abstract ( inherits EmailMessage_Base and adds some business logic including what default return addresses are and
3
2214
by: Goran Djuranovic | last post by:
Hi all, Is there a way to retrieve a derived class name inside a subroutine or a function of the base class? I am trying to get some data from the database, based on which derived class is calling the subroutine. I know the base class name can be retrieved by using reflection namespace: System.Reflection.MethodBase.GetCurrentMethod.DeclaringType.Name. Thanks Goran
2
2404
by: cmonthenet | last post by:
Hello, I searched for an answer to my question and found similar posts, but none that quite addressed the issue I am trying to resolve. Essentially, it seems like I need something like a virtual static function (which I know is illegal), but, is there a way to provide something similar? The class that is the target of my inquiry is a template class that interfaces to one of several derived classes through a pointer to a base class. The...
3
1661
by: Ravi | last post by:
Is this the correct way to think of "base class"? The "base class" is a class from which other classes are derived. The "base class" will never be derived from another class.
0
8265
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8705
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8504
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4092
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4197
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2625
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1808
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1511
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.