forward declaration of a template class?

N

Nobody

what is the syntax for a forward declaration of a template class?


normally I declare all my classes at the top of the header:

class CClass1;
class CClass2;

class CClass1 : public CBase
{
};

class CClass2 : public CBase
{
}

this doesn't seem to work with a template class? I get all sorts of errors.
 
J

John Harrison

Nobody said:
what is the syntax for a forward declaration of a template class?


normally I declare all my classes at the top of the header:

class CClass1;
class CClass2;

class CClass1 : public CBase
{
};

class CClass2 : public CBase
{
}

this doesn't seem to work with a template class? I get all sorts of errors.


template <class T>
class X;

is perfectly good template class forward declaration.

If that doesn't help then perhaps you should post the code you are actually
having trouble with. And mention the compiler since many compilers have a
few quirks when it comes to templates.

john
 
N

Nobody

Ooops... I figured it out. I was using a default param in the template. I
had to remove that from the definition and only use it in the forward
declaration.
 

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,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top