|
From: Robert A. <ral...@gm...> - 2005-05-16 22:59:04
|
How about just fully qualifying what main you want to make your friend... t=
ry
friend int ::main(void);
On 5/16/05, Alfred P. Reaud <al...@ya...> wrote:
> Possibly declare main as a friend in the private section of MyClass
> instead? Also, I'd get away from calling a friend member function main o=
r
> Main, due to what the linker may try to do with that label.
>=20
> Farzan Hajian <far...@ho...> wrote:=20
> 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();
> };
> }
>=20
> 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,
> <snip>
>=20
> =20
> =20
>=20
> Alfred P. Reaud
|