Is containment or compositon, public inheritance?
Private members become accesible only through the base class interface.
Does this mean private members of the contained class are only accesible through the public methods of that class?
Is containment or compositon, public inheritance?
Private members become accesible only through the base class interface.
Does this mean private members of the contained class are only accesible through the public methods of that class?
i can't help you out much, but i'm pretty sure composition is not public inheritance. as far as i know, it's only declaring an object of class A within class B, and then passing the arguments to the newly created object.
>Private members become accesible only through the base class interface.
i think that's refering to the fact that two derived classes of the same base class do not have proteced acces to each other.
that's all i know right now. hope i helped a little?
This is true for public inheritance.Originally posted by rip1968
Does this mean private members of the contained class are only accesible through the public methods of that class?
class A
{
public:
int getNum( );
private:
int num;
};
class B
{
public:
int getNum( );
};
int B::getNum( )
{
return A::getNum( ); //cannot directly access A::num
}
//sorry for the lag of tags, this was written on the fly