Created
April 15, 2013 10:41
-
-
Save Gohan/5387248 to your computer and use it in GitHub Desktop.
base, proxy
This file contains 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 <cstdio> | |
class Base | |
{ | |
public: | |
int Print() | |
{ | |
return printf("Base\n"); | |
} | |
}; | |
template<int N1> | |
class Proxy : public Base | |
{ | |
public: | |
}; | |
template<> | |
class Proxy<0>:public Base | |
{ | |
public: | |
void Print() | |
{ | |
printf("void Print() :"); | |
Base::Print(); | |
} | |
}; | |
template<> | |
class Proxy<1>:public Base | |
{ | |
public: | |
int Print() | |
{ | |
printf("int Print() :"); | |
return Base::Print(); | |
} | |
}; | |
int main() | |
{ | |
Base base; | |
Proxy<0> p0; | |
Proxy<1> p1; | |
Proxy<2> p2; | |
p0.Print(); | |
p1.Print(); | |
p2.Print(); | |
base.Print(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment