Thread View: comp.std.c++
3 messages
3 total messages
Started by Ron Burk
Mon, 18 Mar 1996 22:58
Forward declaration of class member functions
Author: Ron Burk
Date: Mon, 18 Mar 1996 22:58
Date: Mon, 18 Mar 1996 22:58
26 lines
1519 bytes
1519 bytes
I am having difficulty finding language in the draft
that establishes the legality or illegality of the following:
class Forward;
class Any {
friend int Forward::SomeFunc(int SomeArg);
};
It certainly seems like a useful construct, and I don't
see any impossibility in implementing it, but I don't
have a compiler that accepts it (in fact, the Borland C++ v5.0
beta gets an internal compiler error on it). Can anyone
point me to relevant language in the draft that resolves
this question?
Thanks,
Ron Burk
Windows Developer's Journal
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Re: Forward declaration of class member functi
Author: Steve Clamage
Date: Tue, 19 Mar 1996 04:53
Date: Tue, 19 Mar 1996 04:53
28 lines
1809 bytes
1809 bytes
In article 199603182248040068@msn.com, "Ron Burk" <RonBurk@msn.com> writes:
>I am having difficulty finding language in the draft
>that establishes the legality or illegality of the following:
>
>class Forward;
>
>class Any {
> friend int Forward::SomeFunc(int SomeArg);
> };
It is not valid. You cannot mention the name of a class member until the
class definition has been seen. To interpret the qualified-id A::B, the name
B must be looked up in the scope of A. If A has not been defined, the lookup
fails, and A::B must be considered undefined. Refer to chapters 3, 9, and 10
of the draft standard.
If this sort of thing were allowed, you could add members to a class
without modifying the class definition, thus violating the One-Definition
Rule.
---
Steve Clamage, stephen.clamage@eng.sun.com
---
[ 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 ]
[ FAQ: http://reality.sgi.com/employees/austern_mti/std-c++/faq.html ]
[ Policy: http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu ]
Re: Forward declaration of class member functions
Author: John E. Potter
Date: Fri, 22 Mar 1996 17:29
Date: Fri, 22 Mar 1996 17:29
42 lines
2060 bytes
2060 bytes
Ron Burk (RonBurk@msn.com) wrote:
: I am having difficulty finding language in the draft
: that establishes the legality or illegality of the following:
: class Forward;
: class Any {
: friend int Forward::SomeFunc(int SomeArg);
: };
: It certainly seems like a useful construct, and I don't
: see any impossibility in implementing it
Not enough of a lawyer to find it; however, the basic idea is that you can
not talk about the inside of something that has not been seen. But I do
see some problems. Let's add a little bit more from another thread
with discussion of a camel's nose inside of the tent.
class Forward::Node; // also illegal
Forward::Node* ptr;
...
class Forward {
private :
class Node {
// ...
};
int SomeFunc(int SomeArg);
};
Now what? You can not talk about a private nested class. You can't call
a private member function. Can you make it a friend? What is the big
picture here?
Enjoy,
John
---
[ comp.std.c++ is moderated. To submit articles: Try just posting with your
newsreader. If that fails, use mailto:std-c++@ncar.ucar.edu
comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
Comments? mailto:std-c++-request@ncar.ucar.edu
]
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads