Re: Problems with templates ???
"Eric M. Hopper" <[email protected]>
| Newsgroups | gmane.comp.documentation.synopsis |
|---|---|
| Organization | Omnifarious Software |
| Message-ID | <[email protected]> |
On Fri, 2004-11-26 at 10:40 +0100, Serge Iovleff wrote:
> In fact with old version of gcc (and many other compiler) it was not
> possible to pre-compile the implementation for template class
> definition. Thus I had to include the impementation in the declaration
> and then to include the resulting file in the program using the
> template class.
>
> If the namespace STK is used for the declaration of "Myclass, in the
> implementation I don't want to write STK::MyClass, thus I think taht
> the 'using namespace' directive is not misplaced.
It is much better to just wrap all the definitions in your .cpp file in:
namespace foo {
}
This is _especially_ true if the .cpp file is included. Because, as
others have pointed out, using namespace has an effect over the entire
compilation unit after the declaration is seen. This may cause people's
code to suddenly act differently and misbehave in strange and unusual
ways just because they included your header file.
Have fun (if at all possible),
--
The best we can hope for concerning the people at large is that they
be properly armed. -- Alexander Hamilton
-- Eric Hopper ([email protected] http://www.omnifarious.org/~hopper) --
signature.asc
(application/pgp-signature, 185 B)
-----BEGIN PGP MESSAGE----- Version: GnuPG v1.2.6 (GNU/Linux) iD8DBQBBqM4gjtsvlOwvazYRAsGWAJ9PSVml1GXudBjy7WDaBT+Jn6U1WACeK41m aThGwcEKylYHZ4oOceBh/QI= =gMDM -----END PGP MESSAGE-----