April 9th, 2009, 10:36 AM
friend class is in none-namespace
I'm looking for a solution with friend concept. The friend class is out of the namespace. It isn't in any namespace. So, is there a solution?
friend class Test2;
}; // end namespace b
b::Test* t = new b::Test();
main.cpp: In member function ‘void Test2::test()’:
main.cpp:11: error: ‘b::Test::Test()’ is private
main.cpp:24: error: within this context
Thank you very much for your time.
April 9th, 2009, 11:12 AM
Re: friend class is in none-namespace
Originally Posted by skywalk
you need to make the friend declaration visible outside the namespace.
When you use new in C++, you must call delete, or else you have a memory leak.
..and um namespace doesn't end with a semi-colon
Last edited by potatoCode; April 9th, 2009 at 11:36 AM.
Reason: fixed something
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.