Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- class Foo {
- public:
- void bar(){
- printf("Foo::bar\n");
- }
- };
- class Baz {
- public:
- void bar(){
- printf("Baz::bar\n");
- }
- };
- class BadClass {
- public:
- void bar(int i){
- printf("BadClass::bar(%d)\n", i);
- }
- };
- template <class T>
- void fun(T arg) {
- arg.bar();
- }
- int main() {
- Foo f;
- Baz b;
- fun(f);
- fun(b);
- BadClass bc;
- fun(bc); //error on compile time
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment