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++ > unnamed namespa...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 43130 of 48044
Post > Topic >>

unnamed namespace and friend method

by John Ratliff <webmaster@[EMAIL PROTECTED] > Feb 6, 2008 at 11:17 AM

Can you declare a friend method if the method is defined in the unnamed 
namespace?

This is basically what I'd like to do:

namespace {
   MyClass *ptr;

   void fnc(unsigned long my_ul, short *my_s_ptr) {
     // blah blah whatever
     ptr->callme();
   }
}

class MyClass {
   friend void fnc(unsigned long, short *);

private:
   void callme();
}

g++ doesn't like this, but all is well if I put things in the global 
namespace.

I suppose I could create a fake namespace, but before I do, can I do 
what I want somehow? I also tried
friend void ::fnc(unsigned long, short *);
but that's no good either.

Thanks,

--John Ratliff
 




 10 Posts in Topic:
unnamed namespace and friend method
John Ratliff <webmaste  2008-02-06 11:17:40 
Re: unnamed namespace and friend method
"Alf P. Steinbach&qu  2008-02-06 17:21:25 
Re: unnamed namespace and friend method
John Ratliff <webmaste  2008-02-06 13:07:36 
Re: unnamed namespace and friend method
"Alf P. Steinbach&qu  2008-02-06 19:33:20 
Re: unnamed namespace and friend method
John Ratliff <webmaste  2008-02-07 23:30:29 
Re: unnamed namespace and friend method
Andrey Tarasevich <and  2008-02-06 17:55:35 
Re: unnamed namespace and friend method
James Kanze <james.kan  2008-02-07 07:07:39 
Re: unnamed namespace and friend method
"Alf P. Steinbach&qu  2008-02-07 18:38:05 
Re: unnamed namespace and friend method
James Kanze <james.kan  2008-02-08 02:32:13 
Re: unnamed namespace and friend method
"Alf P. Steinbach&qu  2008-02-08 17:17:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Wed Oct 15 22:46:03 CDT 2008.