Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Anonymous names...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 6 Topic 44287 of 48417
Post > Topic >>

Anonymous namespaces and friend functions

by Ronald Raygun <invalid@[EMAIL PROTECTED] > Apr 1, 2008 at 02:32 PM

I have the class declared like this in the header fiel:

//header
class MyClass
{
public:
	MyClass();
	MyClass(const MyClass&);
	MyClass& operator=(const MyClass&);
	~MyClass();

	friend int MyFriendFunc(const MyClass&);

private:
	int m_i ;
};


//source
namespace
{
	void MyFriendFunc(const MyClass& mc){ return mc.m_i++ ;}
}

//MyClass impl ...



I get compiltion errors (MyFriendFunc cannot  access private member of 
MyClass ...

using the ns resolution operator does not seem to work either:

friend int ::MyFriendFunc(const MyClass&);
 




 6 Posts in Topic:
Anonymous namespaces and friend functions
Ronald Raygun <invalid  2008-04-01 14:32:46 
Re: Anonymous namespaces and friend functions
"Victor Bazarov"  2008-04-01 10:32:55 
Re: Anonymous namespaces and friend functions
bjeremy <bjeremy@[EMAI  2008-04-01 08:04:50 
Re: Anonymous namespaces and friend functions
Abhishek Padmanabh <ab  2008-04-01 08:09:08 
Re: Anonymous namespaces and friend functions
Andrey Tarasevich <and  2008-04-01 09:59:42 
Re: Anonymous namespaces and friend functions
James Kanze <james.kan  2008-04-02 01:14:24 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Fri Nov 21 9:25:08 CST 2008.