Templated class declaration - c++
This is a discussion on Templated class declaration - c++ ; Hi,
With a normal class, I can do the following:
---
class Foo;
void func( Foo* param );
class Foo
{
//defined here
};
---
How do I declare a templated class before the actual definition?
---
class WStr; // ...
-
Templated class declaration
Hi,
With a normal class, I can do the following:
---
class Foo;
void func( Foo* param );
class Foo
{
//defined here
};
---
How do I declare a templated class before the actual definition?
---
class WStr; // Does not work, the compiler complains about
redifinition.
void func( WStr* param );
template< class T >
class Tmpl
{
//defined here
T* t;
};
typedef Tmpl< char > WStr;
---
Thank you,
Steve
-
Re: Templated class declaration
Steve: wrote:
> Hi,
>
> With a normal class, I can do the following:
>
> ---
> class Foo;
>
> void func( Foo* param );
>
> class Foo
> {
> //defined here
> };
> ---
>
>
> How do I declare a templated class before the actual definition?
>
> ---
> class WStr; // Does not work, the compiler complains about
> redifinition.
template<class T> class Tmpl;
>
> void func( WStr* param );
If this is a concrete function (with a certain template specialisation
as the argument type), then do
void func( Tmpl<char>* param );
If it does not work for you, maybe you can put the declaration after
the definition of 'Tmpl' class.
>
> template< class T >
> class Tmpl
> {
> //defined here
> T* t;
> };
>
> typedef Tmpl< char > WStr;
> ---
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Similar Threads
-
By Application Development in forum c++
Replies: 9
Last Post: 12-07-2007, 12:28 PM
-
By Application Development in forum c++
Replies: 3
Last Post: 12-05-2007, 12:25 AM
-
By Application Development in forum c++
Replies: 14
Last Post: 11-15-2007, 04:46 AM
-
By Application Development in forum c++
Replies: 1
Last Post: 09-29-2007, 09:49 AM