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

problem declaring template

When I try to compile this template:

template <typename T>
class ElementT<std::vector<T {
public:
typedef T Type;
};

I get the error:

main.cpp:11: error: ‘ElementT’ is not a template
make: *** [main.o] Error 1
What is causing this error?
May 2 '07 #1
4 1505
desktop wrote:
When I try to compile this template:

template <typename T>
class ElementT<std::vector<T {
public:
typedef T Type;
};

I get the error:

main.cpp:11: error: ‘ElementT’ is not a template
make: *** [main.o] Error 1
What is causing this error?
What is std::vector<T>? What are you trying to do?
The correct template declaration is:

template <typename T>
class ElementT{
public:
typedef T Type;
};

Regards,

Zeppe
May 2 '07 #2
Zeppe wrote:
desktop wrote:
>When I try to compile this template:

template <typename T>
class ElementT<std::vector<T {
public:
typedef T Type;
};

I get the error:

main.cpp:11: error: ‘ElementT’ is not a template
make: *** [main.o] Error 1
What is causing this error?

What is std::vector<T>? What are you trying to do?
The correct template declaration is:

template <typename T>
class ElementT{
public:
typedef T Type;
};

Regards,

Zeppe
It works if I first type:
template <typename T>
class ElementT;
and then the partial specialization:

template <typename T>
class ElementT<std::vector<T {
public:
typedef T Type;
};
It seems that when doing partial specialization you first need to define
the class as a template.
May 2 '07 #3
desktop wrote:
It works if I first type:
template <typename T>
class ElementT;
and then the partial specialization:

template <typename T>
class ElementT<std::vector<T {
public:
typedef T Type;
};
It seems that when doing partial specialization you first need to define
the class as a template.
Oh, so you wanted to do a template specialization! If you think about
that, it's quite reasonable that you have to define something before
specializing it, isn't it?

Regards,

Zeppe
May 2 '07 #4
"desktop" <ff*@sss.comwrote in message
news:f1**********@news.net.uni-c.dk...
Zeppe wrote:
>desktop wrote:
>>When I try to compile this template:

template <typename T>
class ElementT<std::vector<T {
public:
typedef T Type; };

I get the error:

main.cpp:11: error: ‘ElementT’ is not a template
make: *** [main.o] Error 1
What is causing this error?

What is std::vector<T>? What are you trying to do?
The correct template declaration is:

template <typename T>
class ElementT{
public:
typedef T Type;
};

Regards,

Zeppe

It works if I first type:
template <typename T>
class ElementT;
and then the partial specialization:

template <typename T>
class ElementT<std::vector<T {
public:
typedef T Type; };
It seems that when doing partial specialization you first need to define
the class as a template.
That is correct, although you have "definition" and "declaration" mixed up.
You are trying to *define* a partial specialization without first
*declaring* the general template, which is an error.

- Sylvester Hesp
May 2 '07 #5

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

Similar topics

0
by: r5 | last post by:
I'm using the MIPSpro Compiler and having trouble defining a function template (involving array size specifiers as template arguments) inside a class. The same definition compiles fine outside...
4
by: Mat DeLong | last post by:
I have never been stuck on programming something before to the point I give up... this is a first. I am programming what should be something very easy in C++... using Templates. Here is the code,...
3
by: Jim Luedtke | last post by:
Can someone help me understand what might be going wrong here? I'm writing a class template that looks something like this; /* myclass.h */ #include<vector> using namespace std template...
7
by: Harolds | last post by:
The code below worked in VS 2003 & dotnet framework 1.1 but now in VS 2005 the pmID is evaluated to "" instead of what the value is set to: .... xmlItems.Document = pmXML // Add the pmID...
2
by: pagekb | last post by:
Hello, I'm having some difficulty compiling template classes as containers for other template objects. Specifically, I have a hierarchy of template classes that contain each other. Template...
8
by: flamexx7 | last post by:
Can anybody tell me what is wrong with declaration of pointer p ? template<class Tclass Stack { struct Link { T* data; Link* next; Link(T* dat, Link* nxt) : data(dat), next(nxt) {} }* head;...
2
by: shuisheng | last post by:
Dear All, Assume I have a class template: template<class T, int N = 0> class A { void fun1(); void fun2(); void fun3();
2
by: syang8 | last post by:
Dear all, I am trying to design classes with stream support. Basically, I want the operator << work for the base class and all the derived classes. If the base class is a template class, and...
2
by: jason.cipriani | last post by:
Again I find myself bogged down in template syntax. Here I have a class with a template member function. I know ahead of time what template parameters I will be passing to the function. I do not...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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...
1
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: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.