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

Recommended Answers

All 3 Replies

yeah, I know. I have followed instructions from this web site, except I made different header files for my vectors

Yeah, I figured it out by now.
If I am doing everything inline, then it works

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.