Apparently my previous question was an XY question. So I'm re-framing it here.
I have a class which will need to call a different function to handle an object argument depending on a variable set in it's constructor.
void functionCandidate1(const Type1 & arg1, Type2 & arg2) {// do something}
void functionCandidate2(const Type1 & arg1, Type2 & arg2) {// do something different}
class MyClass{
bool use_function1_;
MyClass(const bool & use_function1): use_function1_(use_function1){
}
void run(const Type1 & arg1){
Type2 obj;
if (use_function1_){
functionCandidate1(arg1, obj);
}else{
functionCandidate2(arg1, obj);
}
}
};
The arguments to each of the functions will be the same but the behavior will be different internally. If possible I would like to avoid calling an if statement on every execution of MyClass::run