Due to these extra steps virtual functions come at an extra cost, both in size and in speed.
"Extra," but relative to what alternative? The typical alternative of storing a "type" data member and switching on that value is generally worse (since the switch has to be done in many places). It's a bit of a disservice to state that virtual functions come at an extra cost without also mentioning that the alternatives also have a cost. There's no free lunch.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
"Extra," but relative to what alternative? The typical alternative of storing a "type" data member and
switch
ing on that value is generally worse (since theswitch
has to be done in many places). It's a bit of a disservice to state that virtual functions come at an extra cost without also mentioning that the alternatives also have a cost. There's no free lunch.