2 ms·
It cannot be overridden by subclasses without risking undefined behavior because there is no this pointer for it to use.
by ryao 1y ago
It cannot be overridden by subclasses without risking undefined behavior because there is no this pointer for it to use.
- 1718627440 1y agoYes it can. It simply means the subclass implementation has no access to a this pointer. When would undefined behaviour occur here? When a function tries to use a parameter that does not exist in the function signature, that's a compile time error not UB. Maybe you think that, because a this pointer is needed for dynamic dispatch? A this pointer exists there, it is just not passed to the implementation.