473,385 Members | 1,817 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,385 software developers and data experts.

A question on multiple-inheritance and its usefullness


Hello fellow C++ experts,
is there any dramatic difference between multiple inheritance:

struct MyType4 : MyType1, MyType2, MyType3 {
int MyInt;
};

and:

struct MyType4 {
MyType1 MyObject1;
MyType2 MyObject2;
MyType3 MyObject3;
int MyInt;
};

?

Is just neat sintactic sugar, or is there something that is impossible
to be achieved with the 2nd solution?

I mean, a function accepting a pointer to MyType2 can accept also a
pointer to a MyType4 object, and that's neat, but I could always pass
&MyObject4.MyObject2 to that function (2nd solution without multiple
inheritance), producing the same result (at least I think). Hence my
question "Is just neat sintactic sugar, or..".

Thanks,
Mike

Aug 9 '06 #1
2 1366
mi**@nospam.com wrote:
Hello fellow C++ experts,
is there any dramatic difference between multiple inheritance:

struct MyType4 : MyType1, MyType2, MyType3 {
int MyInt;
};

and:

struct MyType4 {
MyType1 MyObject1;
MyType2 MyObject2;
MyType3 MyObject3;
int MyInt;
};

?

Is just neat sintactic sugar, or is there something that is impossible
to be achieved with the 2nd solution?

I mean, a function accepting a pointer to MyType2 can accept also a
pointer to a MyType4 object, and that's neat, but I could always pass
&MyObject4.MyObject2 to that function (2nd solution without multiple
inheritance), producing the same result (at least I think). Hence my
question "Is just neat sintactic sugar, or..".
You can't implement virtual functions for MyTypes 1-3 in MyType4
without inheritance. Check out:

http://www.parashift.com/c++-faq-lit....html#faq-25.4

Cheers! --M

Aug 9 '06 #2

mlimber wrote:
mi**@nospam.com wrote:
Hello fellow C++ experts,
is there any dramatic difference between multiple inheritance:

struct MyType4 : MyType1, MyType2, MyType3 {
int MyInt;
};

and:

struct MyType4 {
MyType1 MyObject1;
MyType2 MyObject2;
MyType3 MyObject3;
int MyInt;
};

?

Is just neat sintactic sugar, or is there something that is impossible
to be achieved with the 2nd solution?

I mean, a function accepting a pointer to MyType2 can accept also a
pointer to a MyType4 object, and that's neat, but I could always pass
&MyObject4.MyObject2 to that function (2nd solution without multiple
inheritance), producing the same result (at least I think). Hence my
question "Is just neat sintactic sugar, or..".

You can't implement virtual functions for MyTypes 1-3 in MyType4
without inheritance. Check out:

http://www.parashift.com/c++-faq-lit....html#faq-25.4
See also FAQs 24.2 and 24.3.

Cheers! --M

Aug 9 '06 #3

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

Similar topics

6
by: Rolf Wester | last post by:
Hi, I have a form with a select element with multiple="true". When using the GET method (I suppose the same happens with the POST method) I can seen that the form sends channels=CH1&channels=CH2...
66
by: Darren Dale | last post by:
Hello, def test(data): i = ? This is the line I have trouble with if i==1: return data else: return data a,b,c,d = test()
11
by: Ohaya | last post by:
Hi, I'm trying to understand a situation where ASP seems to be "blocking" of "queuing" requests. This is on a Win2K Advanced Server, with IIS5. I've seen some posts (e.g.,...
6
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. ...
9
by: Abhishek Srivastava | last post by:
Hello All, In IIS 6.0 We have a concept of worker processes and application pools. As I understand it, we can have multiple worker process per appliction pool. Each worker process is dedicated...
9
by: Graham | last post by:
I have been having some fun learning and using the new Controls and methods in .Net 2.0 which will make my life in the future easier and faster. Specifically the new databinding practises and...
2
by: areef.islam | last post by:
Hi, I am kinda new to javascript and I am having this problem with selecting multiple options from a select tag. Hope someone can help me out here. here is my code...
1
by: abhishekhs | last post by:
Hi all I have more than one multiple select lists in a page. Something like this <tr> <td> <select NAME="StrainList" ID="StrainList" SIZE="5" multiple="multiple" style="width: 150px"> <?...
35
by: keerthyragavendran | last post by:
hi i'm downloading a single file using multiple threads... how can i specify a particular range of bytes alone from a single large file... for example say if i need only bytes ranging from...
58
by: bonneylake | last post by:
Hey Everyone, Well recently i been inserting multiple fields for a section in my form called "serial". Well now i am trying to insert multiple fields for the not only the serial section but also...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.