Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- template <class T1> class foo {
- public:
- template <class T2> static void bar();
- };
- template <class T1>
- template <class T2>
- void foo<T1>::bar() {
- printf("Hello World GENERIC\n");
- }
- template<>
- template<>
- void foo<int>::bar<float>() {
- printf("Hello World IF\n");
- }
- template<>
- template<>
- void foo<float>::bar<int>() {
- printf("Hello World FI\n");
- }
- int main() {
- // prints Hello World IF
- foo<int>::bar<float>();
- // prints Hello World Generic
- foo<float>::bar<float>();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement