How do I friend the class within a namespace?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

//class groups::BaseGroup;
class Base{
public:

	//friend class groups::BaseGroup;
private:
};

/*----*/

namespace groups{

class BaseGroup{
public:
private:
	Base square;
};

}; //namespace groups


So what I want is, I want Base to friend BaseGroup, but BaseGroup is within a namespace and the syntax I'd expect to work isn't.
Try just class BaseGroup and friend class BaseGroup. If that doesn't work, I dunno.
You have to declare class A within the namespace before referring to it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
namespace ns
{
class A;
}

class B
{
    friend class ns::A;
};

namespace ns
{
class A
{
    A() {}
};
}

cool thanks, that worked.
Topic archived. No new replies allowed.