Q:

access protected member from separate class

This is an over simplification of what I am working with because there is a lot of code. So I have two classes. A is the parent of Aa and X is the parent of Xx. I set the parent A as a friend class of X and Xx so that I can access its private and protected variables . Now because Aa is the child of A and inherits from A why can't I access the protected members of X or Xx? A is a friend class so shouldn't this work? I always get an error saying that barA is a protected member of X.
class A {
    friend class X;
    friend class Xx;
public:
    void FooA();
protected:
    int fooA;
};

class Aa: public A {
public:
    voif Fooa();
private:
    int fooa;
};

class X {
public:
    void BarA();
protected:
    int barA;
};

class Xx: public X {
public:
    void Bara();
private:
    int bara;
};

A:

When you write friend class X; and friend class Xx; it means member functions of X and Xx can access private and protected members of class A. It seems you want the reverse. For that you should add friend class Aa in class X and Xx.

