With Visual Studio 2003 you can use member template functions, for example:
class Foo {
template <class T>
};
that you can call in this way:
void main() {
int a = 10;
Foo obj;
obj.bar(a);
}
Make sure that when you declare the bar method you include also the method definition otherwise you will end-up with a linker error.
1 comment:
C++ Function templates are those functions which can handle different data types without separate code for each of them. For a similar operation on several kinds of data types, a programmer need not write different versions by overloading a function. It is enough if he writes a C++ template based function. This will take care of all the data types.
Post a Comment