473,396 Members | 1,749 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,396 software developers and data experts.

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

Oct 2 '07 #1
1 1458
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 Tclass 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
Oct 2 '07 #2

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

Similar topics

5
by: Pete C. | last post by:
I'm trying to make a templated function a friend like this: class cls { ... friend cls func<> (const cls& a, const cls& b); }; template< template<class> class Op> cls func (const cls& a,...
2
by: ferdinand.stefanus | last post by:
Hi, I have some questions regarding templated class constructor: #include <iostream> using namespace std; template<typename T> class Foo { public:
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...
15
by: kwikius | last post by:
Hi all, I have been searching through the list of papers at: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/ I seem to remember a proposal regarding templated namespaces e.g: template...
9
by: axel22 | last post by:
Hello, I have the following problem. I create a class called MyClass which includes another class calles MyContainer. Class MyContainer has a member which is a vector, instantiated as...
1
by: cpunerd | last post by:
Hello, I'm not new to C++, but for some reason, until now I'd never had a need for deriving templated classes. Now though, I find myself seeing a weird problem. If I have a templated base class...
7
by: mosfet | last post by:
HI, when trying to compile an embedded version of STL called ustl on win32 platform I get the following error : /// Returns the minimum of \p a and \p b template <typename T1, typename T2>...
1
by: Ralf Goertz | last post by:
Victor Bazarov wrote: Yes, you're right, they don't. At least not with my compiler. Is there a reason for this? I also tried to use a forward declaration of Derived2 before the definition of...
2
card
by: card | last post by:
Hi everyone, I have a question about referencing a nested class contained within a templated class. Of course the best way to show you is by example. Here's my templated classes: #include...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...

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.