template class problem

now i want to use this template function inside a class , but if i did so i would be forced to edit all the class member functions . i.e can i make a certain member function template without rewwriting the whole class.

another problem is that even if i modified the whole class i would be forced to write :
A <int> object1;
for example

can i simply put it in global domain(i mean outside the class) and then call it . but is'nt this against encapsulation

>>little ugly
Is it?
This is the correct way to the thing what you want.
You create a class template when you want to separate the implementation of the whole class according to the template parameter. But here, this is not what you want to do.
In fact, you could templatize the class along with a different function template:

Note the use of two templates, the first is the class and the second is the function. There are explicit rules about specialization, which if you are after I recommend posting another question / reading about them in the standard / or experimenting. But I have given the general case.

Now, you have to be a little careful. As I have written it all in one file, there is no problem BUT if you separate the files, then you are going to have to have either explicit or implicit template instatiation. That means if you have a file, say Aclass.cpp and Aclass.h, which have the code and the defiintion of the class, and you use in in another file say main.cpp. There is no way for the compiler to know that it needs a print<unsigned int> for example. If the code is in the actual definition (e.g. Aclass.h) then there is not problem.

So to get round that is automatically is (a) compiler specific, (b) dramatically increases compile time. So you can just ignore the problem and with a couple of flags to the compiler/linker you will be happy. However, it is often better to do it explicitly and then it is (a) certain to work on ANY compiler [very useful when porting stuff] (b) it compiles much faster. This is also important, more so than most beginners think. and (c) it creates earlier and better error messages.