Why can't I change a private member of a class from a friend class in a different namespace?
<p>I am finding trouble accessing a private member of a class from a friend class.</p>

<p>The class that holds the private member I want to change and the class where the change is made are in different namespaces.</p>

<p>The friend class is defined after the class holding the data, so I've tried to forward declare the friend class outside the namespace.</p>

<p>g++ says that I can't modify the member because it's private, visual studio seems to think it's fine.</p>

<p>Am I doing some weird non-standard thing here? Why can't I change the member? Here is a simplified snippet that represents my problem:</p>

<pre><code>struct S;

namespace N
{
    class A
    {
        int m;
    public:
        A():m(5){};
        friend struct S;
    };

}

using namespace N;

struct S
{
    A&amp; a;
    S(A&amp; a):a(a) {}
    void changeA(){ a.m = 9; }
};

int main()
{
    A a;
    S s(a);
    s.changeA();
}
</code></pre>
