Search code examples
c++visual-studio-2012template-classes

c++: unable to match function definition to an existing declaration


HERE IS WHERE HOW I DECLARED IT IN THE PUBLIC OF "template"

void print();

HERE IS TO PRINT

template<class T>
T XArray<T>::print()
{

    for ( int i = 0; i < size; ++i)
        cout << Array[i] << " ";
    cout << "\n\n";

}

I don't know what I'm doing wrong.


Solution

  • Your definition is saying that print returns a T, but your declaration says it return void. Change it to

    template<class T>
    void XArray<T>::print()