|
From: Farzan H. <far...@ho...> - 2005-05-16 06:39:47
|
Dear C++ users,
I have problem with friend functions and namespaces.
Assume we have class "MyClass" defined in namespace "MyNameSpace":
namespace MyNameSpace
{
class MyClass
{
private:
int data;
public:
int func(){}
friend int main();
};
}
using namespace name;
int main()
{
C obj;
obj.data;
return 0;
}
I want to allow "main()" to access private members so I made it friend =
=20
for the class. Since "main()" does not belong to "MyNameSpace" the =20
compiler can not make it a friend for the class. It trys to find a =20
"main()" function which belongs to the namespace not a "Main()" function =
=20
outside.
Now I want to k now if there is solution for this problem.
Thanks,
--=20
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
|