Re: Problem with friend function and gcc 4.2 with objective-c++
Re: Problem with friend function and gcc 4.2 with objective-c++
- Subject: Re: Problem with friend function and gcc 4.2 with objective-c++
- From: Thomas Engelmeier <email@hidden>
- Date: Wed, 13 Aug 2008 10:45:16 +0200
Am 09.08.2008 um 16:32 schrieb Clark Cox:
On Sat, Aug 9, 2008 at 2:20 AM, Thomas Engelmeier
<email@hidden> wrote:
Am 08.08.2008 um 00:09 schrieb Ken Worley:
friend != static, and even then this probably would not be valid
semantics.
test1* tobj = newtest1(5); has nothing to do with
test1::newtest1( int ) or aTest1Instance->newtest1( int )
I believe that you are incorrect. This is a perfectly valid way of
defining friend functions in C++. Defined this way, newtest1 is a
global function (i.e. it is not scoped to test) that is allowed to
access the private/protected parts of test1 instances.
From the C++ standard (11.4 paragraph 5):
"
A function can be defined in a friend declaration of a class if and
only if the class is a non-local class (9.8),
the function name is unqualified, and the function has namespace
scope. [Example:
class M {
friend void f() { } //definition of globalf, a friend ofM,
//not the definition of a member function
};
—end example] Such a function is implicitlyinline. Afriendfunction
defined in a class is in the
(lexical) scope of the class in which it is defined.
"
OOPs.. OK, I just did some cursory research how the friend syntax (I
rarely used) is like...
Regards,
Tom_E
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden