Re: Is there anyway to forward reference a namespace like STL?
- From: Victor Bazarov <v.Abazarov@xxxxxxxxxxxx>
- Date: Fri, 19 Aug 2005 18:42:08 -0400
Bruce Stemplewski wrote:
Is there anyway to forward reference a namespace like STL?
I can forward reference a class in my header file like this.
class MyClass;
That's call a "forward declaration".
class AnotherClass {
MyClass *c;
That's just using the forward declaration. You can actually omit the forward declaration and write
class MyClass *c;
here.
}
This way I do not need to include the header to MyClass in the header for AnotherClass.
But how would I do this for something that uses a namespace like STL?
std::vector< Route* > *m_coll;
There is no need to forward declare a namespace. Namespaces can be reopened:
namespace std {
// whatever
}but you don't really need that, do you? What you need is the ability to forward-declare 'std::vector'... That's rather difficult because you don't know how many and what arguments to give it.
Why can't you simply include <vector> in the file where you declare your m_coll pointer? I know you probably don't want to, but is there a technical reason why you can't? I bet there isn't. You could add a forward-declaration of the 'std::vector', but in that case you will tie yourself up with a particular implementation of it (and you really don't want to do that, trust me). Just include the damn header.
V .
- Follow-Ups:
- Re: Is there anyway to forward reference a namespace like STL?
- From: Simon Trew
- Re: Is there anyway to forward reference a namespace like STL?
- References:
- Is there anyway to forward reference a namespace like STL?
- From: Bruce Stemplewski
- Is there anyway to forward reference a namespace like STL?
- Prev by Date: Is there anyway to forward reference a namespace like STL?
- Next by Date: Re: DLL and its icon
- Previous by thread: Is there anyway to forward reference a namespace like STL?
- Next by thread: Re: Is there anyway to forward reference a namespace like STL?
- Index(es):
Relevant Pages
|
Loading