Friendship Members

This entire problem is going to be theoretical. If I tried to use the example that I am experiencing the problem with it would be too long.

Problem: I created Class B inside of Class A and made Class B a friend of Class A.
1
2
3
4
5
6
7
8
9
10
11
class B {
    public:
    B::B();
};

class A {
    friend class B;

    public:
    A::A();
};


Class A has an object inside of it that class B needs to access. It is a private selection box.

1
2
3
4
5
6
7
8
9
10
11
12
class B {
    public:
    B::B();
};

class A {
    friend class B;
    cp::cpSelectionBox *List;

    public:
    A::A();
};


I try to access it from inside of B like: A::List[index];, but it says:
error: object missing in reference to 'A::List'|


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class B {
    public:
    B::B();

    Access() {
        A::List[0] = "Choice 1";
    }
};

class A {
    friend class B;
    cp::cpSelectionBox *List;

    public:
    A::A();
};
List is not static, so it must be accessed by an A object.
Or maybe what you are trying to do is make B a child class of A?

Also, you might want to define A before B if you want B to know about A's members.
If I make List static will I be able to change the values?
Yes, you will be able to modify them. However, that static object will be the same in ALL class As, so you can't have two different selection boxes for 2 different As.
Oh okay I see. Let me try it.
Topic archived. No new replies allowed.