back

by vardump·12y ago·view on hn ↗
Even single inheritance with multiple subclasses makes following the potential code paths mentally as many times harder as there are classes that extend or override the common base class.

Operator overloading; looks like we agree.

Exceptions do control flow, even if you just use them to report errors. They're often effectively hidden gotos.

2 comments
> Even single inheritance with multiple subclasses makes following the potential code paths mentally as many times harder as there are classes that extend or override the common base class

But that is a property of inheritance and virtual functions, not something inherent to C++. You could be using another object-oriented language and the logic would be as hard to follow. We could discuss why or why not that property is problematic, but that would be straying from the topic, which is C++.

> Exceptions do control flow, even if you just use them to report errors. They're often effectively hidden gotos.

Again, same logic can be applied to any language that supports exceptions.

>Even single inheritance with multiple subclasses makes following the potential code paths mentally as many times harder as there are classes that extend or override the common base class.

Composition over inheritance is a technique used to reduce this problem.

[1] http://en.wikipedia.org/wiki/Composition_over_inheritance