Results 1 to 5 of 5

Thread: How can you make a private data member inheritable in C++

  1. #1
    Join Date
    Dec 2010
    Posts
    66

    How can you make a private data member inheritable in C++

    I am a software programmer by profession , although I am a web designer by profession , I have learned a bit of web developing languages such as PHP , HTML, XML, since I had chosen web development when I was asked for the electives in my college days, but I am trying to do a bit of development as to earn myself a bit of extra earning, So I started with the C++ language , since I have already learned C language and wanted to brush some basics of C++, but I forgot few things in it , can any one please tell me how can I inherit the private data , I would ask you people to comment on this , and I will appreciate if any programmer or developer replies comment on this question, waiting for your response.

  2. #2
    Join Date
    May 2009
    Posts
    511

    Re: How can you make a private data member inheritable in C++

    C++ inheritance is very alike to a parent-child association. When a class is deriving all the methods and data member are derived , although not all of them will be available by the member functions of the child class. But there are some exceptions for this case as well. It is a well known actuality that the private and protected members are not reachable outside the class. But a base class is given access to protected members of the parent class.

  3. #3
    Join Date
    May 2009
    Posts
    529

    Re: How can you make a private data member inheritable in C++

    Yes I too think that way so I have made a list . Some of those exceptions prominent in C++ inheritance are given below :

    • The constructor and destructor of a parent class are not subject to inheritance.
    • The assignment operator also cannot be inherited.
    • there are some special functioned normally named as friend functions/ methods and classes named as friend classes of the parent class, these functions and classes also cannot be inherited.
    • There are few facts to be pondered about C++ inheritance.
      • The protected and public identifiers or members of the parent class are all easy to get to in or accesses by the child class.
        But a private member variable not accessible by a derived class.

  4. #4
    Join Date
    May 2009
    Posts
    543

    Re: How can you make a private data member inheritable in C++

    Well I totally disagree with this fact , because this will totally change the meaning of the word private, what does the word private public , it states that it will be not available in public, so it clearly implies that the data members that has been declared as private in the private class or the base class cannot be accessed by any of the class that has been derived from that existing base class, yes it can be in the case of a protected access modifier but not in the private at all, I am not that much friendly with the C++ though, but I can tell you that it is not possible. In case if anyone does come across to this way , please post your ideas.

  5. #5
    Join Date
    Jun 2011
    Posts
    1

    Re: How can you make a private data member inheritable in C++

    The derived class object can access the private data of parent class indirectly through the member functions of the parent class accessible to it.

Similar Threads

  1. How to make Windows 7 user's folder private
    By AkshatShetty in forum Operating Systems
    Replies: 7
    Last Post: 08-09-2011, 11:14 PM
  2. How to make a maplestory private server
    By guest69 in forum Video Games
    Replies: 3
    Last Post: 12-11-2009, 12:19 PM
  3. Can i make my Twitter account private
    By G.randhir in forum Technology & Internet
    Replies: 2
    Last Post: 07-09-2009, 08:15 PM
  4. Firefox 3.5 does not delete all private data
    By Triple-X in forum Technology & Internet
    Replies: 3
    Last Post: 31-08-2009, 08:13 PM
  5. How to make your own runescape private server
    By Jaheel in forum Tips & Tweaks
    Replies: 1
    Last Post: 22-07-2009, 09:19 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,203,570.61436 seconds with 17 queries