C++ template specialization | Sololearn: Learn to code for FREE!

0

C++ template specialization

Hello everyone! Is it possible to use template specialization for ALL functions in a class? If yes, can you give an example please?

10/21/2018 4:01:48 PM

H2727

2 Answers

New Answer

+2

Yeah you can specialize the class itself. template<typename T> class Foo { void speak () { cout << "Hello from Foo<T>"; } } template<> class Foo<int>{ void speak () { cout << "Hello from Foo<int>; } }

0

Thanks