Topic: friend declaration syntax
Author: kprateek88@yahoo.com (Prateek R Karandikar)
Date: Thu, 13 May 2004 05:43:10 +0000 (UTC) Raw View
A class definition body declares 4 kinds of names : private members,
protected members, public members, and friend non-members. Why aren't
there 4 sections reflecting this? :
class A
{
private:
//...
protected:
//...
public:
//...
friend:
//...
};
Such an arrangement would be more consistent, since IMO logically it
doesn't make sense to place friend declarations in the private,
protected, or public sections, since they are not members (of the
class in which they are declared friend) in the first place.
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: richard@ex-parrot.com (Richard Smith)
Date: Thu, 13 May 2004 14:20:38 +0000 (UTC) Raw View
kprateek88@yahoo.com (Prateek R Karandikar) wrote in message news:<607f883e.0405120750.5031029d@posting.google.com>...
> A class definition body declares 4 kinds of names : private members,
> protected members, public members, and friend non-members. Why aren't
> there 4 sections reflecting this? :
> class A
> {
> private:
> //...
> protected:
> //...
> public:
> //...
> friend:
> //...
> };
>
> Such an arrangement would be more consistent, [...]
I don't think it would be more consistent. Ordinarily, if I declare a
member function,
class X {
// ...
void foo();
};
I know that this is a non-static member function, and it can, for
example, access non-static other members via the `this' pointer.
Similarly, I would (usually) expect to see a definition of it:
void X::foo() { /* ... */ }
Neither of these are true for friends.
I think a better analogy is with static member functions which, of
course, are declared using the `static' keyword on every function.
--
Richard Smith
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]