linking errors when using templates

M

murali

Hi,

I get tollowing linking errors

Main.cpp:30 undefined reference to
Matrix<int>::Matrix[in-charge](int,int)

whats that '[in-charge]' and what might be the problem ??

line 30 of main: Matrix<int>::Matrix(array,int rows,int cols)

and the matching (supposed to be) constructor is
Matrix<T>::Matrix(const T *array,int rows,int cols)

even for the default constructor call I get the same linking error

I'am driven to edge of sanity... plz help


Thanks,
 
J

John Harrison

murali said:
Hi,

I get tollowing linking errors

Main.cpp:30 undefined reference to
Matrix<int>::Matrix[in-charge](int,int)

whats that '[in-charge]' and what might be the problem ??

line 30 of main: Matrix<int>::Matrix(array,int rows,int cols)

and the matching (supposed to be) constructor is
Matrix<T>::Matrix(const T *array,int rows,int cols)

even for the default constructor call I get the same linking error

I'am driven to edge of sanity... plz help


Thanks,

For the sake of your sanity, you should have tried

1) searching this newsgroup or
2) reading the FAQ.

This question gets asked several times a month. The answer is always the
same.

Put all the template code in the header file.

http://www.parashift.com/c++-faq-lite/containers-and-templates.html#faq-34.14

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top