473,320 Members | 2,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

forward declaration of a template class?

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.
Jul 22 '05 #1
2 11265

"Nobody" <no****@cox.net> wrote in message
news:%lFWb.28941$1O.21160@fed1read05...
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
Jul 22 '05 #2
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.

"John Harrison" <jo*************@hotmail.com> wrote in message
news:c0*************@ID-196037.news.uni-berlin.de...

"Nobody" <no****@cox.net> wrote in message
news:%lFWb.28941$1O.21160@fed1read05...
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

Jul 22 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: mjm | last post by:
Folks, Please help me with the following problems: ******************************************** 1. I have a class template template<class Base> class Matrix : public Base { /* .... */ }
2
by: jobseeker | last post by:
From: jobseeker95479@yahoo.com (jobseeker) Newsgroups: comp.lang.c++.moderated Subject: template and forward declaration NNTP-Posting-Host: 131.233.150.22 I have defined a class that contains a...
6
by: Steven T. Hatton | last post by:
Should I be able to forward declare something from a namespace different from the current one? For example the following code compiles: //testdriver.hpp #ifndef TESTDRIVER_HPP #define...
2
by: verec | last post by:
Consider a first version: --- drawable.hpp --- #include "gcdata.hpp" struct drawable { ... virtual int internal_new_GC(gcdata * gcd) = 0 ; } ; --- gcdata.hpp ---
1
by: Vince | last post by:
Hi, I have a templated class implemented in one file called CDynWnd.h and declared like this : CDynWnd.h (declaration and implementation) ------------ template <class BASECLASS> class...
23
by: mark.moore | last post by:
I know this has been asked before, but I just can't find the answer in the sea of hits... How do you forward declare a class that is *not* paramaterized, but is based on a template class? ...
7
by: Noah Roberts | last post by:
I have something like the following: template<ENUM X, int I = 0> class Generic { .... }; typedef Generic<Val1> v1_type; typedef Generic<Val2> v2_type;
6
by: Hunk | last post by:
Hi I have a question on usage of forward declarations of templates. While searching through this group , people suggested using forward declarations and typedefs for templates as // in...
5
by: aaragon | last post by:
Hello, I was wondering if it is possible to forward declare a type definition. If so, what is the way to do it? I found a couple of messages where they say it's not possible but there must be a way...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.