Hello,
I want to build up an inheritance structure looking like two coupled dreaded
diamonds. It's similar to an old posting of me. Now my question is, where
to use the keyword virtual.
CV
/ \
/ \
V CDV
\ / \
\ / \
DV CMI
\ /
\ /
MI
I placed virtual like this:
V : public virtual CV
CDV : public virtual CV
DV : public virtual CDV, public V
CMI : public virtual CDV
MI : public DV, public CMI
My porblem is, that the construction process of an MI does not do the
conctructor calls, I would expect. There is a constructor
MI(const CDV &rhs) : DV(rhs) {} // CMI has a default constructor.
which calls
DV(const CDV &rhs) : V(rhs) {} // CDV has a default constructor.
and now I would expect
V(const CV &rhs) {} // CV has a default constructor.
to be called, but actually
V() {}
is called. And here I wonder. Where am I wrong. I hope I provided enough
information. Else ask please. All classes are template classes by the way,
if relevant.
regards,
alex 1 2013
"Alexander Stippler" <st**@mathemati k.uni-ulm.de> wrote in message news:3f******@n ews.uni-ulm.de... V() {}
is called. And here I wonder. Where am I wrong. I hope I provided enough information. Else ask please. All classes are template classes by the way, if relevant.
All virtual base classes are initialized by the most derived object before any
non-virtual bases. It is the constructor of your most derived class (MI) that
needs to pass any arguments to the virtual bases.
MI(const CDV& rhs) : DV(rhs), CV(rhs) { }
or the like.
The order of construction of your heirarchy is:
CV, CDV, V, DV, CMI, MI This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alexander Stippler |
last post by:
I've got an inheritance structure with two coupled "dreaded diamonds" like
shown below:
A
/ \
/ \
B C
\ / \
\ / \
D E
\ /
|
by: Corno |
last post by:
Hi all,
I know there are quite a few arguments in favor or against MI. I know there
are a lot of usenet discussions about wether MI is actually needed or not.
These discussions mention the 'dangers' of MI.
The problem is; I know that there are dangers concerned with MI and I know
how I can avoid them, I just don't have a clear idea of what the dangers
actually are and if they are applicable to to the situations I encounter.
The only...
|
by: puzzlecracker |
last post by:
I am sure people are familiar with dirty diamond problem solved by
virtual inheritance. look at the code below and tell me how many
instances of the base class (in this case A) does class D receive?
class A
{
:
:
|
by: Xavier |
last post by:
Hi,
I have a question, in a "dreaded diamond" situation, regarding the
following code:
---- Begin code
#include <iostream>
using namespace std;
|
by: emma middlebrook |
last post by:
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-lite/multiple-inheritance.html#faq-25.8
..
Base
/ \
| |
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: 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: 2005 |
last post by:
Hi
What is the purpose of declaring a class with a "Virtual" in front?
What is the benefit?
Thanks
|
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: 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,...
|
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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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: 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...
| |