What are you expecting the above lines to do? They do nothing.
You really need to move the contents of A.cpp and B.cpp to their header files, as otherwise you will need to #include the .cpp files directly whereever you use A or B, and that is very poor practice.
But even if I move the contents of A.cpp and B.cpp to their respective header files then again it is again the same because neways i have to include their header files. So, how does it solve the purpose on including the contents of .cpp files to their header files.
Still I am confused as to what should I do? Should the templates always be included completely in header files?? Or there is some trick to separate the header files and .cpp files
Template Specialization is the term. I want to know what is the best way to specialize a template so that I don't need to write a new specialization in the template .cpp file everytime I want to use a new spcialized class. Is there any way for that?
No my concern is not this. Everytime I need a spcialization I need to do that in template .cpp file. So, suppose in the future I want to use a user-defined object. Then I have to do its specialization in template .cpp file. I want a method so that I don't touch the template .cpp file.
And still I can do template specialization for my own choice of objects.
Typically template classes are implemented wholly in header files. You can put specializations in any file you like; you just need to make sure the compiler sees the general one first and the specialized one second.