Fix invoking virtual functions from constructors

Virtual functions should not be invoked from a constructor or destructor
of the same class. Confusingly, virtual functions are resolved
statically (not dynamically) in constructors and destructors for the
same class. The call should be made explicitly static by qualifying it
using the scope resolution operator.
This commit is contained in:
Mingjie Shen 2023-05-24 14:28:33 -04:00 committed by rusefillc
parent e9fd6e9fa7
commit 495f0ea8c4
2 changed files with 4 additions and 4 deletions

View File

@ -54,7 +54,7 @@
TriggerDecoderBase::TriggerDecoderBase(const char* name)
: name(name)
{
resetState();
TriggerDecoderBase::resetState();
}
bool TriggerDecoderBase::getShaftSynchronized() {

View File

@ -25,7 +25,7 @@ void Pid::initPidClass(pid_s *parameters) {
this->parameters = parameters;
resetCounter = 0;
reset();
Pid::reset();
}
bool Pid::isSame(const pid_s *parameters) const {
@ -190,12 +190,12 @@ void Pid::updateITerm(float value) {
PidCic::PidCic() {
// call our derived reset()
reset();
PidCic::reset();
}
PidCic::PidCic(pid_s *parameters) : Pid(parameters) {
// call our derived reset()
reset();
PidCic::reset();
}
void PidCic::reset(void) {