473,624 Members | 2,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 11283

"Nobody" <no****@cox.net > wrote in message
news:%lFWb.2894 1$1O.21160@fed1 read05...
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.2894 1$1O.21160@fed1 read05...
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
5459
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
14144
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 data member of a function type. The signature of the function type take a pointer of the class itself as a parameter: class Softkey; // forward declaration
6
5197
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 TESTDRIVER_HPP #include <ostream> namespace ns_testdriver{ using std::ostream;
2
2395
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
2068
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 CDynWnd : public BASECLASS
23
3839
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? Here's what I thought should work, but apparently doesn't: class Foo; void f1(Foo* p)
7
5983
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
8611
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 myfile.h template<typename T,typename R> class some_class;
5
6992
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 to do it. Thank you. a²
0
8231
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8471
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7153
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6107
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5561
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4075
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4167
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1474
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.