Jump to content

  • Log In with Google      Sign In   
  • Create Account

#Actual0r0d

Posted 09 March 2013 - 02:09 AM

I don't know how to accomplish this. Do I need some template tricks?

 

You could do it with virtual functions, or if you dont want virtual functions at all then you can do like this with templates:

 

template <int N> 
class Base
{
public:
	int getSpecialNum(void){ return N; }
};

class A : public Base<0>{};
class B : public Base<1>{};
class C : public Base<2>{};
class D : public Base<3>{};

#10r0d

Posted 09 March 2013 - 02:08 AM

I don't know how to accomplish this. Do I need some template tricks?

 

You could do it with virtual functions, or if you dont want virtual functions at all then you can do like this with templates:

 

template <int T> 
class Base
{
public:
	int getSpecialNum(void){ return T; }
};

class A : public Base<0>{};
class B : public Base<1>{};
class C : public Base<2>{};
class D : public Base<3>{};

PARTNERS