I submitted some code as:
Abstract class:
virtual void someFunction(std::vector<someObject*> & iObject) = 0;
virtual void someFunction(std::vector<someObject*> & iObject, bool aSwitch) = 0;
The first function was existing, I added the second to avoid having a default value parameter in a pure method.
Header in the derived class:
virtual void someFunction(std::vector<someObject*> & iObject);
virtual void someFunction(std::vector<someObject*> & iObject, bool aSwitch = false);
Usage as expected:
someFunction(std::vector<someObject*> & Object);
or
someFunction(std::vector<someObject*> & Object, true);
someFunction as it was - already existed, I added the switch. It works well but I'm confused.
I have a code reviewer saying I should include a default value in the pure virtual function to avoid the two function signatures. I remember reading that default values in pure virtuals are not a good idea but I can't argue a valid point and the articles dont seem clear as to why.
Would it cause ambiguity if I added the default value and if so would I still need the default value in the derived virtual method?
Could I just add the default value in the pure virtual function and do away with the first function in the derived class header? What is the best practice here?