unknow error

1
2
3
4
5
6
7
8
9
10
11
12
13
my compiler is giving me an error that vector is not template I'm using visual studio 2012
template <>
class vector <bool>
{
    // interface

    private:
    unsigned int *vector_data;
    int length;
    int size;
};
	
 
Out of interest, what are you trying to do?

The template<> tells the compiler that you're trying to specialise a template class called vector. So you have your own class template vector? Or are you trying to specialize std::vector? If the former, I'd use a different name to avoid any possible confusion with std::template.

But why do you need to specialize?

And what does the comment "interface" refer to??

Andy
leave the comment for name doesn't mater if i use
1
2
3
tempalte <>
class A<char>

then the compiler again give me same error
1
2
3
4
5
template<typename T>
struct MyClass
{
    //...
};
then the compiler again give me same error

Because you're still not specializing an existing template.

1
2
3
4
5
6
7
8
9
10
11
12
13
// the template
template <typename T>
class A
{
    // whatever you need to do to variables of type "T"
};

// the specialization of the existing template A for char
template <>
class A<char>
{
    // whatever you want to do to specialize A for char
};


See the "Template specialization" section on this page:

Templates
http://www.cplusplus.com/doc/tutorial/templates/

Andy
Last edited on
Topic archived. No new replies allowed.