anyone knows what is virtual path inheritance ?

This is a discussion on anyone knows what is virtual path inheritance ? within the C++ Programming forums, part of the General Programming Boards category; i have seen this word in interview question . i don't know if this kind of thing is existing or ...

  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
    20,959
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User
    Join Date
    Jun 2005
    Posts
    5,827
    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%.

  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
    20,959
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 12: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, 12:15 AM
  4. C++ XML Class
    By edwardtisdale in forum C++ Programming
    Replies: 0
    Last Post: 12-10-2001, 10: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

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