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++ Moderated > Re: How to decl...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 6 of 6 Topic 9502 of 9830
Post > Topic >>

Re: How to declare the type in the class?

by dizzy <dizzy@[EMAIL PROTECTED] > Apr 16, 2008 at 11:36 AM

red floyd wrote:

> Chris Uzdavinis wrote:
>> On Apr 15, 2:27 pm, slatp <songli9...@[EMAIL PROTECTED]
> wrote:
>> 
>>> //1.h
>>> struct A {
>>>   enum B{a,b,c};
>>> };
>>>
>>> //2.h
>>> struct C {
>>>  void func(A::B m);
>>> };
>> 
>>> how to declare enum B?
>> 
>> Currently, enums cannot be forward declared, and so you must pull
>> in the definition which is only found in the header you call "1.h"
>> You must therefore #include "1.h"
>>
> 
> Anybody know if this is subject to change in the draft for C++0x?  I
> think that forward declaration of enum would be very useful.

As per http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2565.html
we
have "blessed by evolution":
N2499    Forward declaration of enumerations   Alberto Ganesh Barbati
or directly
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2499.pdf

I don't understand why there won't be forward declaration sup****t for ANY
type (well maybe not any, but any object type such as struct/class, enums,
integral types, template instantiations, etc). The im****tant aspect is
that
the compiler should be able to work with pointers/references to such
forward declared types without requiring them to be only of struct/class
(I
can understand that some pointer types, such as pointers to member
functions cannot be treated the same but for pointers to object types it
should work).

This way then we can reduce "include" clutter alot (without the penalty of
an additional layer of indirection as per PIMPL idiom). While I try to
forward declare every struct/class instead of including the definitions I
can't do it for typedefs that can be to native types for example.

-- 
Dizzy


      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 6 Posts in Topic:
How to declare the type in the class?
slatp <songli9447@[EMA  2008-04-15 12:27:54 
Re: How to declare the type in the class?
Chris Uzdavinis <cuzda  2008-04-15 23:21:52 
Re: How to declare the type in the class?
=?ISO-8859-1?Q?Daniel_Kr=  2008-04-15 23:22:24 
Re: How to declare the type in the class?
red floyd <no.spam@[EM  2008-04-16 04:13:18 
Re: How to declare the type in the class?
=?ISO-8859-1?Q?Daniel_Kr=  2008-04-16 11:34:14 
Re: How to declare the type in the class?
dizzy <dizzy@[EMAIL PR  2008-04-16 11:36:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan12V112 Fri Jul 25 15:29:29 CDT 2008.