Forward declarations
From: Marcin Kalicinski (kalita_at_poczta.onet.pl)
Date: 05/11/04
- Next message: Pete Becker: "Re: The future of C++"
- Previous message: Bill Seurer: "Re: best result function"
- Next in thread: Leor Zolman: "Re: Forward declarations"
- Reply: Leor Zolman: "Re: Forward declarations"
- Reply: Jake Montgomery: "Re: Forward declarations"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 11 May 2004 16:35:12 +0200
Hi All,
In some headers meant to work with both C and C++ the following is often
found:
typedef struct tagMyStruct { /*some members*/ } MyStruct;
Can I forward-declare MyStruct somehow?
Or more generally, can I forward declare a typedef or an enum? Also, is
there any reason why there should be difference between forward declarations
of classes and structs (i.e. why I need to explicitly write keyword 'struct'
or 'class' when forward declaring). In some cases I don't immediately know
what to write, because, for example, the type definition in original header
file is generated with some macro, such as this:
STDINTERFACE(IBlahBlah, IBaseBlahBlah) {
/* Members */
}
Now I need to search for the definition of STDINTERFACE to see how it works.
Even if I find it, it still may silently change in some future version of
the header file, and cause my compilation to fail. Wouldn't allowing a
generic form of forward declaration, without introducing a new keyword:
typename IBlahBlah;
be beneficial to C++?
best regards,
Marcin
- Next message: Pete Becker: "Re: The future of C++"
- Previous message: Bill Seurer: "Re: best result function"
- Next in thread: Leor Zolman: "Re: Forward declarations"
- Reply: Leor Zolman: "Re: Forward declarations"
- Reply: Jake Montgomery: "Re: Forward declarations"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|