Template Specialization
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
Hi, I was wondering if it was possible to change only one member function in a template specifialization and have the rest the same without having to duplicate the code in the specifialized class? Thanks.
Yes-- Just define the specialization of the function in the header file after the template definition. Like this:
template <typename foo> class bar { public : int func1() { ... } int func2() { ... } ... } // Specialization of func2 in bar for class q template<> bar<q>::func2() { ... }