Hey guys, I'm working on converting some existing Java Code over to C++, trying to use only built in standard libraries because the platform we are building on we won't be able to have any outside libraries, and it's been a while since I had to write "fancy" c++ code so here is probably an easy question for you.
I have a base class in Java that is a Number as a return type, each of its chidren return a different type (int, double, float etc). Also have a function that takes an object in java, and each child acts differently on it.
public abstract class Base{
...
public abstract Number doSomething();
public abstract void setMe(Object blah);
...
}
public class Child1 extends Base{
...
public Number doSomething(){
value= new Double(somedouble);
return value;
}
public void setMe(Object blah){
value=(Double)value;
}
What would be the best way to go about this? C++ doesn't have a generic like Number.. can I use a template in c++ aka template<class Number>.
Do I have to do anything special to make that work? Also this will be on a Linux system.