Thread: anyone knows what is virtual path inheritance ?

  1. #1
    Registered User
    Join Date
    May 2010
    Posts
    18

    Thumbs up anyone knows what is virtual path inheritance ?

    i have seen this word in interview question .
    i don't know if this kind of thing is existing or not. may be it is same as multiple path inheritance(diamond problem)!

  2. #2
    Registered User C_ntua's Avatar
    Join Date
    Jun 2008
    Posts
    1,853
    Look here

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    18
    Quote Originally Posted by C_ntua View Post
    Look here
    it is example of diamond problem.
    are you saying that diamond problem is a virtual path inheritance or it is any inheritance in which class is inherited with virtual keyword?

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    I have never heard of the specific term "virtual path inheritance", but C_ntua seems to think that it is the same thing as virtual inheritance.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    6,815
    The "diamond of death" refers to a derived class having more than one instance of a base class through multiple inheritence, in circumstances where only one instance is wanted.

    An example of the hierarchy is;
    Code:
    class Base
    {
        // members
    };
    
    class A : public Base
    {
        // members
    };
    
    class B : public Base
    {
        // members
    };
    
    class Derived : public A, public B
    {
        // members
    }
    Problems associated with the "diamond of death" are resolved by declaring the Base to be a virtual base of both A and B.

    Doing this achieves what is sometimes described as "virtual path inheritence". Personally, I consider it a woeful description, but some people seem to like it.
    Right 98% of the time, and don't care about the other 3%.

    If I seem grumpy or unhelpful in reply to you, or tell you you need to demonstrate more effort before you can expect help, it is likely you deserve it. Suck it up, Buttercup, and read this, this, and this before posting again.

  6. #6
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    Did anybody here actually ever encounter this problem? I've coded quite a lot in C++, all object oriented, but I've never created a diamond pattern...

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by EVOEx
    Did anybody here actually ever encounter this problem? I've coded quite a lot in C++, all object oriented, but I've never created a diamond pattern...
    There is the rather famous example of std::basic_ios, std::basic_istream, std::basic_ostream and std::basic_iostream.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Inheritance and pure virtual functions
    By Swerve in forum C++ Programming
    Replies: 3
    Last Post: 03-12-2010, 01:30 PM
  2. Replies: 48
    Last Post: 09-26-2008, 03:45 AM
  3. Virtual function and multiple inheritance
    By George2 in forum C++ Programming
    Replies: 68
    Last Post: 02-13-2008, 01:15 AM
  4. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 11:14 PM
  5. Exporting Object Hierarchies from a DLL
    By andy668 in forum C++ Programming
    Replies: 0
    Last Post: 10-20-2001, 01:26 PM