472,962 Members | 2,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Inheritance problem

Hi again!

I'm having problems with inheritance. I have a base interface class
called IObject. Next I have two other interfaces classes, IControl and
ICommandMaster, which derives from IObject.

My problem is that I have a /third/ class, CCommand, which derives from
both IControl and ICommandmaster...

The error message says (Weird.....)
ambiguous access of 'Release' in 'Win32::Controls::CCommand'
could be the 'Release' in base 'CS::IObject::Release'
or the 'Release' in base 'CS::IObject::Release'

Is there a way to solve this ambiguety, or am I lost?

The ICommandMaster is an interface which is used in menus, command
buttons, toolbars and any other that might send a command.
Jul 22 '05 #1
3 2412
"Morten Aune Lyrstad" <mo****@wantsno.spam> wrote in message
news:0X******************@news4.e.nsc.no...
I'm having problems with inheritance. I have a base interface class called
IObject. Next I have two other interfaces classes, IControl and
ICommandMaster, which derives from IObject.

My problem is that I have a /third/ class, CCommand, which derives from
both IControl and ICommandmaster...

The error message says (Weird.....)
ambiguous access of 'Release' in 'Win32::Controls::CCommand'
could be the 'Release' in base 'CS::IObject::Release'
or the 'Release' in base 'CS::IObject::Release'

Is there a way to solve this ambiguety, or am I lost?


This is the typical caveat with multiple inheritance, described
in every OOP/C++ book.
So typical that this suspiciously looks like homework...

CControl contains to independent instances of the base class IObject,
and this can create all kinds of problems.

Anyway, three common solutions are:
- derive both IControl and ICommandmaster from IObject using
virtual inheritance:
class IControl : public virtual IObject { ..... };
class ICommandmaster: public virtual IObject { ..... };
- Eliminate the use of multiple inheritance...
- override the Release method (and maybe the equivalent Acquire?)
in the common subclass, and make it call the method of
a specific base class:
class CCommand { ......
virtual void Release() { IControl::Release(); }
};

Good luck,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com
Jul 22 '05 #2
Ivan Vecerina wrote:
"Morten Aune Lyrstad" <mo****@wantsno.spam> wrote in message
news:0X******************@news4.e.nsc.no...
I'm having problems with inheritance. I have a base interface class called
IObject. Next I have two other interfaces classes, IControl and
ICommandMaster, which derives from IObject.

My problem is that I have a /third/ class, CCommand, which derives from
both IControl and ICommandmaster...

The error message says (Weird.....)
ambiguous access of 'Release' in 'Win32::Controls::CCommand'
could be the 'Release' in base 'CS::IObject::Release'
or the 'Release' in base 'CS::IObject::Release'

Is there a way to solve this ambiguety, or am I lost?

This is the typical caveat with multiple inheritance, described
in every OOP/C++ book.
So typical that this suspiciously looks like homework...

CControl contains to independent instances of the base class IObject,
and this can create all kinds of problems.

Anyway, three common solutions are:
- derive both IControl and ICommandmaster from IObject using
virtual inheritance:
class IControl : public virtual IObject { ..... };
class ICommandmaster: public virtual IObject { ..... };
- Eliminate the use of multiple inheritance...
- override the Release method (and maybe the equivalent Acquire?)
in the common subclass, and make it call the method of
a specific base class:
class CCommand { ......
virtual void Release() { IControl::Release(); }
};

Good luck,
Ivan


Thanks for your quick reply. No, actually, it is not a homework problem.
I am writing a win32 ui library. The reason I don't know about this is
that I am 100 % self taught, no books no nuthin'. So there's a billion
and one things I don't know. For example:

Virtual inheritance is something new to me. Could you please fill me in
on the basics?

Yours,
Morten Aune Lyrstad
Jul 22 '05 #3
"Morten Aune Lyrstad" <mo****@wantsno.spam> wrote in message
news:Uc******************@news4.e.nsc.no...
Thanks for your quick reply. No, actually, it is not a homework problem. I
am writing a win32 ui library. The reason I don't know about this is that
I am 100 % self taught, no books no nuthin'. So there's a billion and one
things I don't know. For example:

Virtual inheritance is something new to me. Could you please fill me in on
the basics?


Hi Morten,
You could try a book such as Thinking in C++ -- a free pdf version of it is
available online: http://www.mindview.net/Books/TICPP/...ngInCPP2e.html
I would suggest reading vol 2 chapter 6.

You also find more texts on this topic using:
http://www.google.com/search?q=virtual%20base%20class

Cheers,
Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Jul 22 '05 #4

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

Similar topics

2
by: AIM | last post by:
Error in msvc in building inheritance.obj to build hello.pyd Hello, I am trying to build the boost 1.31.0 sample extension hello.cpp. I can not compile the file inheritance.cpp because the two...
14
by: Steve Jorgensen | last post by:
Recently, I tried and did a poor job explaining an idea I've had for handling a particular case of implementation inheritance that would be easy and obvious in a fully OOP language, but is not at...
22
by: Matthew Louden | last post by:
I want to know why C# doesnt support multiple inheritance? But why we can inherit multiple interfaces instead? I know this is the rule, but I dont understand why. Can anyone give me some concrete...
8
by: Gaetan | last post by:
hi i have 2 classes A1 and A2 implementing a problem with 2 different ways i also have 2 other classes X1 and X2 implementing an other problem i need classes that provide A1+X1 methods,...
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...
60
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...
5
by: colint | last post by:
Hi I'm fairly new to c++ and I have a question regarding inheritance. I'm trying to create a class based on 2 inherited classes, e.g. class A { ... } class B: public A
5
by: a | last post by:
Hi, I have an oop inheritance graph problem. What is the difference betweent the following 2 inheritance graph? How does the C++ solve the naming conflict problem for multiple inheritance...
3
by: Leo Seccia | last post by:
Hello everyone, I have a c# project with a sql server database. I have a number of lookup tables in my database which I successfully managed to import into my LINQ dataclasses. eg. Table:...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.