Last active
August 29, 2015 14:11
-
-
Save dmikurube/2167ec2e08aab0d30444 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
class Base { | |
public: | |
virtual void common_func(int arg) { | |
std::cout << "Bas" << arg << std::endl; | |
} | |
}; | |
template <class A> | |
class B { | |
public: | |
void func(A arg) { | |
std::cout << "Baz" << arg << std::endl; | |
} | |
}; | |
template<> | |
class B<int> : public Base { | |
public: | |
void func(int arg) { | |
std::cout << "Bar" << arg << std::endl; | |
} | |
virtual void common_func(int arg) { | |
std::cout << "Woz" << arg << std::endl; | |
} | |
}; | |
template<> | |
class B<double> : public Base { | |
public: | |
void func(double arg) { | |
std::cout << "Bal" << arg << std::endl; | |
} | |
}; | |
template<> | |
class B<char> { | |
public: | |
void func(char arg) { | |
std::cout << "Var" << arg << std::endl; | |
} | |
}; | |
template <class A> | |
class C : public Base { | |
public: | |
void func(A arg) { | |
std::cout << "Caz" << arg << std::endl; | |
} | |
}; | |
template<> | |
class C<char> { | |
public: | |
void func(char arg) { | |
std::cout << "Kar" << arg << std::endl; | |
} | |
}; | |
int main() { | |
B<int> b_int; | |
b_int.func(12); | |
b_int.common_func(194); | |
B<char> b_char; | |
b_char.func('f'); | |
// b_char.common_func('a'); | |
B<double> b_double; | |
b_double.func(1.31); | |
b_double.common_func(491); | |
B<float> b_float; | |
b_float.func(1.14); | |
// b_float.common_func(4333); | |
C<int> c_int; | |
c_int.func(391); | |
c_int.common_func(1955); | |
C<char> c_char; | |
c_char.func('$'); | |
// c_char.common_func(104194); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bar12
Woz194
Varf
Bal1.31
Bas491
Baz1.14
Caz391
Bas1955
Kar$