can someone please explain the hiding principle in inheritance ?

This is a discussion on can someone please explain the hiding principle in inheritance ? within the C++ Programming forums, part of the General Programming Boards category; basically i don't understand when and how to use it... Thanks in advance,...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    3

    can someone please explain the hiding principle in inheritance ?

    basically i don't understand when and how to use it...

    Thanks in advance,

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,112
    What do you mean by "the hiding principle in inheritance"? Are you talking about abstraction and/or encapsulation (which is separate from inheritance), or are you talking about name hiding in 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

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    3

    i'm talking about the name hiding

    i'm talking about the name hiding

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,112
    Quote Originally Posted by sharon182
    i'm talking about the name hiding
    Personally, I have not encountered a case where it was useful. In Effective C++, 3rd Edition, Meyers discusses why name hiding exists:
    The rationale behind this behavior is that it prevents you from accidentally inheriting overloads from distant base classes when you create a new derived class in a library or application framework. Unfortunately, you typically want to inherit the overloads. In fact, if you're using public inheritance and you don't inherit the overloads, you're violating the is-a relationship between base and derived classes that Item 32 explains is fundamental to public inheritance. That being the case, you'll almost always want to override C++'s default hiding of inherited names.
    I assume that you are aware of how this problem can be solved by using a using declaration.
    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
    Jan 2011
    Posts
    3

    thanks very much !! little bit clear...

    Quote Originally Posted by laserlight View Post
    Personally, I have not encountered a case where it was useful. In Effective C++, 3rd Edition, Meyers discusses why name hiding exists:

    I assume that you are aware of how this problem can be solved by using a using declaration.
    .....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Hiding programs
    By Jay_Tech in forum Windows Programming
    Replies: 4
    Last Post: 10-16-2002, 12:55 AM
  2. Hiding window
    By xlnk in forum Windows Programming
    Replies: 2
    Last Post: 09-27-2002, 04:29 PM
  3. Help with hiding CMenu in MS-VS C++ 6
    By streetd in forum Windows Programming
    Replies: 1
    Last Post: 09-06-2002, 05:27 PM
  4. hiding windows
    By canine in forum Windows Programming
    Replies: 2
    Last Post: 08-21-2002, 05:06 PM
  5. principle components analysis
    By mijter in forum C++ Programming
    Replies: 0
    Last Post: 04-18-2002, 08:48 AM

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