Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #12019
| From | Victor Bazarov <v.bazarov@comcast.invalid> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: C++ puzzle - how to get this to compile ? |
| Date | 2011-12-02 11:12 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <jbatda$li0$1@dont-email.me> (permalink) |
| References | <1e5dd913-1403-42b9-bcc1-527ee7a31dbb@p2g2000vbj.googlegroups.com> <4ed8700f$0$4366$7b1e8fa0@news.nbl.fi> |
On 12/2/2011 1:28 AM, Juha Nieminen wrote:
> OSS542<jhart666@gmail.com> wrote:
>> class cls2
>> {
>> friend void cls1::fun1();
>> };
>> class cls1
>> {
>> cls2 mbr1;
>> public:
>> void fun1();
>> };
>
> In principle there's no technical reason why that couldn't be done. It's
> just a question of lacking syntax in the language.
>
> It would be useful if one could, somehow, declare member functions before
> the class definition is known. (If the class then fails to define the
> declared member function, a linker error would happen.) This can be done
> with namespaces, but not with classes.
>
> I'd say a syntax like this would be enough:
>
> class A;
> int A::foo(int, int);
>
> Anyone see any problem with that?
I think you're advocating forward-declaration of member functions. In
that case the full qualification should be allowed for forward-declaring
static, virtual, default, pure virtual and const members of the class.
Basically there shouldn't be a problem if you want to write
virtual int A::foo(int,int) const = 0;
outside the class itself. However, currently the grammar does not allow
the keyword 'virtual' to be used outside a class definition, and also
defines a different meaning of the keyword 'static'.
I don't see "any problem" except that the grammar needs to be made even
more complicated to allow out-of-the-class-definition member declarations.
V
--
I do not respond to top-posted replies, please don't ask
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
C++ puzzle - how to get this to compile ? OSS542 <jhart666@gmail.com> - 2011-11-30 16:24 -0800
Re: C++ puzzle - how to get this to compile ? Bart v Ingen Schenau <bart@ingen.ddns.info> - 2011-12-01 13:54 +0100
Re: C++ puzzle - how to get this to compile ? OSS542 <jhart666@gmail.com> - 2011-12-06 13:08 -0800
Re: C++ puzzle - how to get this to compile ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-01 11:34 -0600
Re: C++ puzzle - how to get this to compile ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-01 13:52 -0500
Re: C++ puzzle - how to get this to compile ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-01 13:53 -0500
Re: C++ puzzle - how to get this to compile ? Paavo Helde <myfirstname@osa.pri.ee> - 2011-12-01 16:03 -0600
Re: C++ puzzle - how to get this to compile ? Juha Nieminen <nospam@thanks.invalid> - 2011-12-02 06:28 +0000
Re: C++ puzzle - how to get this to compile ? Victor Bazarov <v.bazarov@comcast.invalid> - 2011-12-02 11:12 -0500
Re: C++ puzzle - how to get this to compile ? Juha Nieminen <nospam@thanks.invalid> - 2011-12-02 16:36 +0000
csiph-web