3 ms·
That's a fair point, but unfortunately in C++ the various types of polymorphism often do not play nicely together. Look at any on-line forums discussing C++. I
by Chris_Newton 16y ago
That's a fair point, but unfortunately in C++ the various types of polymorphism often do not play nicely together.
Look at any on-line forums discussing C++. If you're a bit more cynical, look at a list of tricky C++ interview questions instead. :-)
You'll find discussions about overloading vs. overriding for class member functions. You'll find discussions of which function gets called when you have both overloaded functions and function templates to consider. You'll find discussions of which sequences of implicit conversions are allowed, and via what mechanisms.
A very high proportion of the nasty edge cases for which C++ has become infamous are caused by trying to combine different forms of polymorphism. I'm all for knowing your tools and evaluating all the options, but I can see why in practice a lot of teams do stick almost entirely to (for example) using classes/OOP and avoiding templates.
- DougBTX 16y agoI get the impression that the answer is no, but is there much use of templates in C++ to make generic classes like in Java/C#?