How do I access a class from within a class defined above it?
<p>If I have classes A and B, how can I create a reference to B inside of A? I read that you need  use a pointer or a reference, but I can't find out more than that. Here's an example of what I'm talking about:</p>

<pre><code>class B;

class A {
    public: 

    B * b_pointer;

    void setSelf(B * given_b_pointer) {
        b_pointer = given_b_pointer;
    };

    void printBName() {
        print (b_pointer.my_name);
    };
};

class B {
    public:

    string my_name;

    void setSelf(string my_given_name) {
        my_name = my_given_name;
    };
}
</code></pre>

<p>This gives me several errors. What am I doing wrong, and how can I fix it?</p>

<p>EDIT: The relevant error message:</p>

<blockquote>
  <p>error: request for member 'my_name' in '((B*)this)->A::b_pointer', which
  is of non-class type 'B*'.</p>
</blockquote>

<p>Error message slightly edited to replace actual class names with psuedo-class names.</p>
