View Poll Results: What do you think of Multiple Inheritence?

Voters
12. You may not vote on this poll
  • I think its great

    6 50.00%
  • I think its ok

    4 33.33%
  • I think its a waste of time

    2 16.67%

Multiple Inheritence

This is a discussion on Multiple Inheritence within the C++ Programming forums, part of the General Programming Boards category; Do you think multiple inheritence is a good thing or is it useless?...

  1. #1
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052

    Multiple Inheritence

    Do you think multiple inheritence is a good thing or is it useless?

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,700
    New to C++? Of course it's not useless, bonehead. But yeah, don't overuse it if possible. It can lead to a very bad framework if you let it get out of hand. Mostly single-purpose classes are inherited that way actually.
    Code:
    bool fun(bool value)
    {
        return std::pow(std::exp(1), std::complex<float>(0, 1) 
        * std::complex<float>(std::atan(1)*(1 << (value + 2))))
        .real() > 0;
    }

  3. #3
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Multiple inheritence is good so long as you don't get carried away with it (it can create overhead).

  4. #4
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    >> New to C++?

    Uh, NO! I was just wondering last night what others thought about it
    Last edited by face_master; 12-11-2002 at 02:59 AM.

  5. #5
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    I don't find it to be such a retarded question. It is one of those things that you could easily make programs without using.

  6. #6
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    It's said that Barne Starjodsodiufskdfjwlkefjwoijfiwejflkjasdkjfl~~~~

    the creator of C++ didn't like multiple inheritance and only put it in after the ATT board made him.
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  7. #7
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Originally posted by OneStiffRod
    It's said that Barne Starjodsodiufskdfjwlkefjwoijfiwejflkjasdkjfl~~~~

    the creator of C++ didn't like multiple inheritance and only put it in after the ATT board made him.
    How could they make him? It was his language

  8. #8
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    AT&T was the technical owner of the lang. since he worked for them when he developed it - it was ATT who encouraged it's release to the public and helped him develop it to that point - he is known as a "FELLOW" at ATT along with his counterparts who run the research and science board for ATT.
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  9. #9
    Code Monkey Davros's Avatar
    Join Date
    Jun 2002
    Posts
    812
    >New to C++? Of course it's not useless, bonehead.

    I think that's a little harsh. There's has been a debate raging for many years as to whether multiple inheritance is a good thing or not. Other languages get by without it, i.e. Java & Object Pascal. Instead they have a notion of inheriting interfaces.

    Having said this, there has been one occasion where I've needed multiple inheretance, and nothing else would have done. But such cases are very rare. Normally you should try to avoid using it, unless you have to, or it really makes sense in the architecture of your project. For example, CORBA makes significant use of multiple inheritance.
    OS: Windows XP
    Compilers: MinGW (Code::Blocks), BCB 5

    BigAngryDog.com

  10. #10
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    Originally posted by OneStiffRod
    AT&T was the technical owner of the lang. since he worked for them when he developed it - it was ATT who encouraged it's release to the public and helped him develop it to that point - he is known as a "FELLOW" at ATT along with his counterparts who run the research and science board for ATT.
    Ok, and, uh...why would AT&T force him to put it in? Why was it so important to them?

  11. #11
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Originally posted by OneStiffRod
    It's said that Barne Starjodsodiufskdfjwlkefjwoijfiwejflkjasdkjfl~~~~

    the creator of C++ didn't like multiple inheritance and only put it in after the ATT board made him.
    I highly doubt that. I've never seen any valid source that makes even the slightest allussion to such a thing, not even in Stroustrups's own books.

    What it comes down to is that multiple inheritance is a powerful tool and does have its uses. Combining implementation is really all that I've used it for. It usually doesn't go very well with polymorphism on many bases simply because the resultant class's instances taking up quite a bit more space than you'd probably want, especially with virtual bases (in most implementations of C++, that is). I only used it once in that manner, but came up with another design for that very reason. While its use with polymorphism and virtual bases is great on a design level, in implementation it will most-likely cause your objects to take up a lot more space in memory. Of course, if you aren't concerned about space, or if there aren't many instances of the class, then it's a perfectly fine thing to do.

    What I usually use it for (and still, I personnaly don't use it an extreme amount) is IE for

    A class Vertex

    A class ColorPacket

    A class TextureCoordinatePacket

    A derived class ColoredVertex inheritted from both Vertex and ColorPacket

    A derived class TexturedVertex inheritted from both Vertex and TextureCoordinatePacket

    A derived class ColoredTexturedVertex inheritted from Vertex, ColorPacket, and TextureCoordinatePacket

    All non-virtual, public inheritance

    ColorPacket and TextureCoordinatePacket both have member functions and data that I wish to use in a "kind of" vertex. With aggregation one would have to make functions that would call the members' functions. It's a hassle. Instead, multiple inheritance is used not to make the resultant classes "kinds of" ColorPackets or "kinds of" TextureCoordinatePackets, but are used just as ways of combining the implementations.
    Last edited by Polymorphic OOP; 12-11-2002 at 05:42 AM.

  12. #12
    Registered User
    Join Date
    Dec 2002
    Posts
    3
    You can read more about C++ language here:

    The Design and Evolution of C++



    >>>

    1) Provides insights into the aims, principles, and real-world constraints which shaped C++,

    2) Describes design decisions for individual language features,

    3) Shows the relationships between C++ language features and the design and programming techniques supported by C++,

    4) Discusses the design of the latest language features: templates, exceptions, run-time type information, and namespaces.

  13. #13
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Why bother, I've got a copy of the book right here

  14. #14
    UNBANNED OneStiffRod's Avatar
    Join Date
    Jan 2002
    Posts
    669
    I got my info from an article written way back in 1994 - I found it on the internet a few months ago - if you look for it I'm sure you'll find it.

    Also, that book will probably tell you the same thing, there are features of C++ that the creator was not too fond of including but the committee insisted.
    My Avatar says: "Stay in School"

    Rocco is the Boy!
    "SHUT YOUR LIPS..."

  15. #15
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078
    Doesn't say anything like that -- in fact, he just talks about how useful it is.

    Here's another tid-bit by Stroustrup specifically about the benefits of Multiple Inheritance.

    http://www.cs.colorado.edu/~diwan/class-papers/mi.pdf

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 06-08-2009, 03:03 PM
  2. why Multiple define error ...
    By nilathinesh in forum C Programming
    Replies: 2
    Last Post: 10-19-2006, 06:31 AM
  3. Phantom redefinition
    By CodeMonkey in forum C++ Programming
    Replies: 6
    Last Post: 06-12-2005, 05:42 PM
  4. Linker errors - Multiple Source files
    By nkhambal in forum C Programming
    Replies: 3
    Last Post: 04-24-2005, 02:41 AM
  5. Replies: 1
    Last Post: 05-01-2003, 02:52 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21