|
-
Feb 5th, 2005, 06:05 PM
#1
Thread Starter
Good Ol' Platypus
Public inheritance... Private members?
Assuming I have two classes, the base containing a private member variable and the other class being derived from base, what is stopping me from accessing that private variable as a member inside of the derived class?
g++ gives me:
'int base::variable' is private
within this context
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 5th, 2005, 06:24 PM
#2
Fanatic Member
Re: Public inheritance... Private members?
-
Feb 5th, 2005, 06:52 PM
#3
Thread Starter
Good Ol' Platypus
Re: Public inheritance... Private members?
OK... makes enough sense, I suppose that private members are really only for the implementation of the actual derived class, so that's where they should be put. Thanks a lot
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Feb 5th, 2005, 08:02 PM
#4
PowerPoster
Re: Public inheritance... Private members?
Use protected instead, that is why it is there.
"From what was there, and was meant to be, but not of that was faded away." - - Steve Damm
"The polar opposite of nothingness is existance. When existance calls apon nothingness it shall return to nothingness." - - Steve Damm
"When you do things right, people won't be sure if you did anything at all." - - God from Futurama
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|