Hello,
I am having problems with templates.
I wrote a templated version of vector. My vector is working. Here is the header file for it:
// m_vector_g.h
template<typename T> class m_vector {
private:
// Some code here...
public:
// Some code here...
};
I want to make another "special" vector just for Boolean values. Here is the header file for it:
// m_vector_b.h
template<> class m_vector<bool>{
private:
// Some code here...
public:
// Some code here...
};
And I am getting these errors:
m_vector_b.cpp:7: error: template-id ‘m_vector<>’ for ‘m_vector<bool>::m_vector()’ does not match any template declaration
m_vector_b.cpp:7: error: invalid function declaration
make: *** [m_vector_b.o] Error 1
This is how I try implement constructor:
template<>
m_vector<bool>::m_vector() {
cout << "i am here " << endl;
}
line 7 is m_vector<bool>::m_vector()
How can I fix this?
Any help is appreciated, thanks