I realized a Matrix class to practice and I have a problem I can not solve!
You need to give us more information.
First, are you compiling the template code separately in another module? If you are, then maybe that is your problem. Template class definition and declaration must be in the same compilation unit, not separate files. I would expect to see something like this:
Note that the implementation must be included with the template code. The reason is that the template needs to be instantiated when it is used, and more than likely the instantiation for double doesn't exist at link time.
If you want a cleaner example, look at the standard headers such as <vector>, <list>, <map>, etc. You see that all the code is within the header, and that is what you should be doing in your example. So remove Mtrx.C from the list of files that are being compiled, and instead include it in the header.
Thanks very much! It was the problem!
And sorry for the stupid question!
I realize few time later, but 'cause of an upcoming exame I did not reply immediatly!
Is it a correct style if I have, however, left the declaration part in the Mtrx.C?
I just added these two lines after the template costructor definition:
Code:
template Mtrx::Mtrx(dim m, dim n, const bool random_constructed, const int min, const int max);
template Mtrx::Mtrx(dim m, dim n, const bool random_constructed, const double min, const double max);
Bookmarks