class A
{
protected:
int m_a;
int m_b;
};
class B: public A
{
};
In class B i want to make m_a private.
Does the following the correct way to do it
class B:public A
{
private:
int m_a;
};
Won’t this result in 2 copies of m_a ?
The
m_ainclass Bshadows that ofclass A. It is a different data member, so class B actually has threeints:A::m_a,A::m_bandB::m_a. The way to get private access tom_ainBis to “use”A::m_aprivately inclass B: