Skip to content

Instantly share code, notes, and snippets.

@Gohan
Created April 15, 2013 10:41
Show Gist options
  • Save Gohan/5387248 to your computer and use it in GitHub Desktop.
Save Gohan/5387248 to your computer and use it in GitHub Desktop.
base, proxy
#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