473,786 Members | 2,398 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem declaring template

When I try to compile this template:

template <typename T>
class ElementT<std::v ector<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 1523
desktop wrote:
When I try to compile this template:

template <typename T>
class ElementT<std::v ector<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::v ector<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::v ector<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::v ector<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.comwro te 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::v ector<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::v ector<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 "declaratio n" 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
1158
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 the class. I have listed a short sample code and resulting error messages at the end of this posting. Is there a known work-around that fixes this "inside the class" problem for SGI compilers -- short of upgrading beyond v7.2.1?
4
2581
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, and the error I get: -------------- namespace LIST { template <typename T> struct Link; template <typename T> class List;
3
1767
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 <class ND> class MyClass {
7
2869
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 parameter to the XSLT stylesheet XsltArgumentList xsltArgList = new XsltArgumentList(); xsltArgList.AddParam("pmID", "", pmID); xmlItems.TransformArgumentList = xsltArgList;
2
3343
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 class B has an instance of template class A, which has some base type T (usually int or double). However, the base type T is important to calculations in B, so I would like to obtain access to the type for further variable declaration within B. ...
8
1979
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; public:
2
1682
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
1978
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 the operator << is also designed as a template function. The program has following linking errors: "error LNK2019: unresolved external symbol "class
2
1862
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 want to define the function in a header, I want to define it in a different translation unit. Here is some code: === a.h === class A { private:
0
10363
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10164
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
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
8989
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...
0
6745
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
5397
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
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
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.