Hi
I come from a C++ background and so am familiar with the 'dreaded
inheritance diamond' i.e. the ambiguity of which data to use when a
class appears twice in the hierarchy. Here's a link for anyone not
familiar: http://www.parashift.com/c++-faq-lit....html#faq-25.8
..
Base
/ \
/ \
/ \
Der1 Der2
\ /
\ /
\ /
Join
Now to my question ... I know an interface inheritance hierarchy of
the same configuration doesn't suffer any problems at all but, to me,
seeing it in a class diagram still makes me feel a little queasy from
a design correctness point-of-view. If anyone feels the same, how do
they best get round the problem. If you don't feel queasy, would you
tell me why I shouldn't either!
Finally, in my particular case I have interfaces IBase and IDerived
(the latter derived from the former), Concrete deriving from IBase,
and then DerivedConcrete deriving from both Concrete and IDerived.
Hence the diamond.
IBase
/ \
/ \
/ \
IDerived Concrete
\ /
\ /
\ /
DerivedConcrete
Thanks very much for your help!
Emma Middlebrook em************* *@fastmail.fm 2 2412
This very topic is discussed here: http://msdn.microsoft.com/library/de...gLanguages.asp
Look for "Single Inheritance"
/Ole
"emma middlebrook" <em************ **@fastmail.fm> wrote in message
news:e2******** *************** ***@posting.goo gle.com... Hi
I come from a C++ background and so am familiar with the 'dreaded inheritance diamond' i.e. the ambiguity of which data to use when a class appears twice in the hierarchy. Here's a link for anyone not familiar:
http://www.parashift.com/c++-faq-lit....html#faq-25.8 .
Base / \ / \ / \ Der1 Der2 \ / \ / \ / Join
Now to my question ... I know an interface inheritance hierarchy of the same configuration doesn't suffer any problems at all but, to me, seeing it in a class diagram still makes me feel a little queasy from a design correctness point-of-view. If anyone feels the same, how do they best get round the problem. If you don't feel queasy, would you tell me why I shouldn't either!
Finally, in my particular case I have interfaces IBase and IDerived (the latter derived from the former), Concrete deriving from IBase, and then DerivedConcrete deriving from both Concrete and IDerived. Hence the diamond.
IBase / \ / \ / \ IDerived Concrete \ / \ / \ / DerivedConcrete
Thanks very much for your help!
Emma Middlebrook em************* *@fastmail.fm
On 18 Apr 2004 15:32, em************* *@fastmail.fm (emma middlebrook)
wrote: Hi
I come from a C++ background and so am familiar with the 'dreaded inheritance diamond' i.e. the ambiguity of which data to use when a class appears twice in the hierarchy. Here's a link for anyone not familiar: http://www.parashift.com/c++-faq-lit...ce.html#faq-25. 8
<snip> Now to my question ... I know an interface inheritance hierarchy of the same configuration doesn't suffer any problems at all but, to me, seeing it in a class diagram still makes me feel a little queasy from a design correctness point-of-view. If anyone feels the same, how do they best get round the problem. If you don't feel queasy, would you tell me why I shouldn't either!
Finally, in my particular case I have interfaces IBase and IDerived (the latter derived from the former), Concrete deriving from IBase, and then DerivedConcrete deriving from both Concrete and IDerived. Hence the diamond.
IBase / \ / \ / \ IDerived Concrete \ / \ / \ / DerivedConcrete
This is one reason that you can explicitly define interface methods, as:
private whatever IDerived.Method FromIBase() {}
To use it a client would have to cast Concrete to Iderived - thus explicit
usage. It's a bit messy, true, and I'd wonder about the design, but not
nearly as bad as MI.
Cheers -
--
Simon Smith
simon dot s at ghytred dot com
NewsLook - NNTP Client for Outlook This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: John Perks and Sarah Mount |
last post by:
Trying to create the "lopsided diamond" inheritance below:
>>> class B(object):pass
>>> class D1(B):pass
>>> class D2(D1):pass
>>> class D(D1, D2):pass
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: Error when calling the metaclass bases
Cannot create a consistent method resolution
|
by: Serena |
last post by:
I am attempting to complete a program with the following format:
Interface2 inherits from Interface1. Both of these are virtual
classes.
Implementation1 inherits from Interface1. Implementation2 inherits
from Interface2 and Implementation1.
When using Implementation2 and a call is made on an operation that is
inherited from Implementation1, the code is entered for Interface1
|
by: Tony Johansson |
last post by:
Hello Experts!!
Assume you have the following diamond inheritance structure.
Assume the following at the top you have the Ancestor class and below this
class
at the same level we have class Child1 and Child2.
Class Descendatnt is derived class Child1 and Child2.
Assume also that in the top class we have one datamember called number and
one method called getNumber(). If you don't use virtual inheritance you will
get compile error.
|
by: MAHESH MANDHARE |
last post by:
Hi ,
Can Anyone explain me exactly why multiple inheritance not used in java and c#
thanks,
Mahesh
--
Have A Good Day,
Mahesh,
Maheshmandhare@yahoo.co.in
|
by: Bruno van Dooren |
last post by:
Hi all,
i am having a problems with inheritance.
consider the following:
class A
{
public:
A(int i){;}
};
| |
by: surendran.d |
last post by:
hi,
can diamond inhertance problem be solved using virtual functions,, or
can only be done with scope resolution operators.. is there any other
way to solve this problem...
Thanks,
suri
|
by: _DD |
last post by:
I've encountered situations that call for an interface but also
require enums/constants that go hand-in-hand with the interface.
Abstract classes won't do, cause I may need to inherit more than one.
Any elegant solutions come to mind?
|
by: Shawnk |
last post by:
Some Sr. colleges and I have had an on going discussion relative to when and
if
C# will ever support 'true' multiple inheritance.
Relevant to this, I wanted to query the C# community (the 'target' programming
community herein) to get some community input and verify (or not) the
following
two statements.
Few programmers (3 to7%) UNDERSTAND 'Strategic Functional Migration
|
by: Paul McGuire |
last post by:
On May 25, 8:37 am, Michael Hines <michael.hi...@yale.eduwrote:
Here's a more general version of your testing code, to detect *any*
diamond multiple inheritance (using your sample classes).
-- Paul
for cls in (A,B,C,D):
seen = set()
|
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...
|
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...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |