Recommended Posts

Okay, I'm trying to get my head around the whole inheritence thing and had a question...
Say I have a base class (base_class) that has a private variable (x). Now, say I derive a new class from base_class called my_class (class my_class: public base_class) that adds a new private variable (y), and a public function that sets both x and y to a value. The compliler tells me I don't have access to x: "cannot access private member declared in class 'base_class'. I thought that as the child class was declared with the 'public' function it would be able to use it's own member functions to access the private varibles inherited from the base class...? Can anyone clear this up?
Cheers!