this is the next question to a friend function in the namespace
If I want testFunc to be in the TestNamespace namespace, but I don't want TestClass to also be in TestNamespace, how can I declare them?
1.This does not work ("expected unqualified identifier before namespace" on line 2)
class TestClass {
namespace TestNamespace {
friend void testFunc(TestClass &myObj);
};
}
namespace TestNamespace {
void testFunc(TestClass &myObj);
}
2. But he complains that "TestNamespace :: testFunc (...) should be declared inside" TestNamespace "when I do this -
class TestClass {
friend void TestNamespace::testFunc(TestClass &myObj);
}
namespace TestNamespace {
void testFunc(TestClass &myObj);
}
3. The above code is fine if I don't have โTestNamespace ::โ in the friend function declaration in line 2, but I'm not sure if he knows that TestNamespace :: testFunc is a friend.
, . . !