Hi!! i'm using templates for the first time and trying to implement it in one the programs which had many constructors taking different types to convert it into a string. I've got most of the part correct and also I read on one of the forums that the constructor and other member functions should be declared in the header file and not in the .cpp file.
Now the problem is I have a static function that returns a string. The code in .cpp file is:
Well I understand that, but if I'm choosing the first option of keeping it all in the header file how do i initialize the member attributes of the class. Also, trying the second method and keeping the method definition in another .cpp file like:
Hi! thanks for that code. However in the mean while what I tried was doing a #include of the .cpp file itself in my main() since I thought its just a linking error and not anything to do with compilation. Now it is working fine, but just want to know is it legit to do this. Is it a good programming technique or is the bit of code given by you a better solution?