using namespace std;
When i put copy the method for the template to the header file theres no errors, but i was thinking an hoping there would be a way to have the methods on a different .cpp file like i showed above. I've tried alot of forums and searched for alot of them, but i had no luck, and alot of their suggestions, for some reason didn't work.
the suggestions that they made are worth trying out if your getting error like the ones i got, unfortunately they didnt work for me as i wanted the template methods to be in a different file partly because it is recommeded for classes, and i wanted it that way.
Anyway I thought hard about this and SUCCESS I've found a way to have the template class in two files and for it to work. The only problem is that it works for me in the situation above, but I'm not sure if it is the correct way that it should be done, so i would like some feedback if posible. thanks.
anyway the way i found to do this is by using include shields #ifndef/endif. the way to do this is to enclose the header file cotaining the template class decleration in the include shield like i've shown below, and also to include the class method file inside the shield, at the end of the class declaration.
template <typename T>
Intervals(T start, T end);
#include <Intervals.cpp> // Includes the template methods file
Then in the class method file, enclose the template class methods with #ifdef/endif, note you dont need to include the header file for the class in this file. see code below.
It took some time for me to figure this out, but i welcome any correction in code or explaination, and comments on whether it works in other situations, bear in mind that I've only tested it for the class templates for my current project.