In C++, what happens when I have the following
class House
{
public:
House();
~House();
private:
int* m_peopleInside;
friend class Room;
};
and then in the constructor of House this is set
m_peopleInside = new int[5];
m_peopleInside[4] = 2;
and
class Room
{
public:
Room();
~Room();
Update();
private:
int* m_peopleInside;
};
Then in the Room.Update() I use m_peopleInside something like this.
&m_peopleInside[4];
It's my understanding that the friend class will allow the Room class to access private members of the House class. So which m_peopleInside would be used?
I should add that in this case, m_peopleInside is being used as an array.