Templated class declaration

S

Steve:

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
 
V

Victor Bazarov

Steve: said:
Hi,

With a normal class, I can do the following:

---
class Foo;

void func( Foo* param );

class Foo
{
//defined here
};

template said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,222
Latest member
patricajohnson51

Latest Threads

Top