about virtual keyword's use in classes

This is a discussion on about virtual keyword's use in classes within the C++ Programming forums, part of the General Programming Boards category; i know the fact that using a virtual keyword in the derived classes(A & B) derived from one base class(Base) ...

  1. #1
    Registered User
    Join Date
    Apr 2013
    Posts
    103

    about virtual keyword's use in classes

    i know the fact that using a virtual keyword in the derived classes(A & B) derived from one base class(Base) removes the ambiguity of the hidden variable of the base class in derived class C (another one) derived from the two derived classes
    ......but how???

  2. #2
    Registered User
    Join Date
    Sep 2008
    Posts
    200
    This section from the C++ FAQ should answer any questions you have about virtual inheritance (but feel free to ask more specific ones if it doesn't).
    Programming and other random guff: cat /dev/thoughts > blogspot.com (previously prognix.blogspot.com)

    ~~~

    "The largest-scale pattern in the history of Unix is this: when and where Unix has adhered most closely to open-source practices, it has prospered. Attempts to proprietarize it have invariably resulted in stagnation and decline."

    Eric Raymond, The Art of Unix Programming

  3. #3
    Registered User
    Join Date
    Apr 2013
    Posts
    103
    i want to know that what happens to the variable of base class when you use virtual keyword in dreaded diamond type inheritance

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    23,796
    Quote Originally Posted by Mukul Kumar
    i want to know that what happens to the variable of base class when you use virtual keyword in dreaded diamond type inheritance
    If you use virtual inheritance correctly, the derived class at the bottom of the hierarchy will only have one sub-object of the base class at the top of the hierarchy.
    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. A simple question about "virtual" keyword
    By meili100 in forum C++ Programming
    Replies: 2
    Last Post: 03-07-2008, 12:05 PM
  2. Trying to use complex.h classes, some keyword is hiding it
    By indigo0086 in forum C++ Programming
    Replies: 4
    Last Post: 02-05-2008, 10:10 PM
  3. Virtual Base Classes
    By skewray in forum C++ Programming
    Replies: 11
    Last Post: 12-21-2006, 05:56 PM
  4. Virtual Keyword
    By Shal in forum C++ Programming
    Replies: 6
    Last Post: 05-18-2006, 11:37 AM
  5. virtual classes and inheritance
    By skora in forum C++ Programming
    Replies: 5
    Last Post: 10-28-2003, 04:28 PM

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