473,394 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

visual inheritance

the following is a theoretical question, this code does not compile in
visual c++ so
my question is, considering c++ virtual inheritance mechanism how many
copies of V is D suppose to have?

class V{virtual f()};
class B1:public virtual V{...};
class B2:public virtual V{...};
class C:public B2, public virtual V{...};
class D: public virtual B1,public virtual B2,public virtual C{...},public
V{...};

thank you
Liz
Jul 19 '05 #1
4 4283
anat wrote:
the following is a theoretical question, this code does not compile in
visual c++ so
my question is, considering c++ virtual inheritance mechanism how
many copies of V is D suppose to have?


One. That is the whole idea.

--
WW aka Attila
Jul 19 '05 #2
anat wrote:

the following is a theoretical question, this code does not compile in
visual c++ so
my question is, considering c++ virtual inheritance mechanism how many
copies of V is D suppose to have?

class V{virtual f()};
class B1:public virtual V{...};
class B2:public virtual V{...};
class C:public B2, public virtual V{...};
class D: public virtual B1,public virtual B2,public virtual C{...},public
V{...};


Two. One virtual (inherited from the various bases) and one non-virtual.

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 19 '05 #3
Pete Becker wrote:
anat wrote:

the following is a theoretical question, this code does not compile
in visual c++ so
my question is, considering c++ virtual inheritance mechanism how
many copies of V is D suppose to have?

class V{virtual f()};
class B1:public virtual V{...};
class B2:public virtual V{...};
class C:public B2, public virtual V{...};
class D: public virtual B1,public virtual B2,public virtual
C{...},public V{...};


Two. One virtual (inherited from the various bases) and one
non-virtual.


Ahh! I have missed that public V. There is a {} before it, that made me
think this is the end of the declaration of the base classes. And I am not
mistaking it will do that to a compiler, too. :-)

--
WW aka Attila
Jul 19 '05 #4
On Mon, 15 Sep 2003 00:36:52 +0200 in comp.lang.c++ :

I took the liberty to change your example to below:

class V{
public:
V() { std::cout << "V\n"; }//virtual int f();
};
class B1:public virtual V
{
public:
B1() { std::cout << "B1\n"; }

};
class B2:public virtual V
{
public:
B2() { std::cout << "B2\n"; }
};
class C:public B2, public virtual V
{
public:
C() { std::cout << "C\n"; }
};
class D:public virtual B1,public virtual B2,
public virtual C,public V
{
public:
D() { std::cout << "D\n"; }
};
int main()
{
D d;
return 0;
}

compiler results:
warning: direct base `B2' inaccessible in `D'
due to ambiguity
warning: direct base `V' inaccessible in `D'
due to ambiguity
output:

V
B1
B2
B2
C
V
D
Jul 19 '05 #5

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

Similar topics

2
by: Matt | last post by:
I have created an MDI child form that I am using as a base form in a VB.Net MDI application. The base MDI child form has a series of menu options on it. I then use this form to create other MDI...
1
by: Jason Hickey | last post by:
Has there been a change in the way the UI designer handles winform inheritance in the 2003 version of visual studio. Consider the following (try it if you are using 2003 Everything seems to work...
30
by: Elhanan | last post by:
hi all i have a question in desgning a form.. the application in question is something a indexing station. the user in this indexing station views a document in pdf/tiff format on the right...
1
by: Paul M | last post by:
Hi folks, I've got a page that contains the basic formatting that I need for pretty much all of my systems pages. It's compiled into it's DLL, distributed to my application's \bin folder and VS...
2
by: Mr Wizard | last post by:
I am going through the front controller http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpatterns/html/ImpFrontControllerInASP.asp and all works well except when the server.transfer...
10
by: Gopal Prabhakaran | last post by:
Hi Pls Help me to do Visual Inheritance with ASP.NET -- Thanx Gopal Prabhakaran
6
by: VR | last post by:
Hi, I read about Master Pages in ASP.Net 2.0 and after implementing some WinForms Visual Inheritance I tryed it with WebForms (let's say .aspx pages, my MasterPage does not have a form tag itself...
6
by: Bart Schelkens | last post by:
Hi, i've created a base-form from which all the forms in my application need to inherit. This works just fine. I've put some buttons on my base-form. They are displayed correctly, only if my...
2
by: Ray Cassick \(Home\) | last post by:
Since I got such good feedback from the Xml comments question I will ask this of the group as well. Is VS.NET 2005 handling the visual inheritance problems centered around controls and forms...
3
by: Dino Buljubasic | last post by:
Hi, I am thinking of using visual inheritance. I am using C# VS 2005. I am concerned about how good it is. I have heard about problems like controls dissapearing or so. Any hints, tips,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
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,...
0
jinu1996
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...
0
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...
0
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...

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.