Hacker News new | past | comments | ask | show | jobs | submit login

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.




I 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#?


Intensive use of templates enables you to build great software (especially in terms of performance), but it requires a certain degree of seniority to be properly used.


All of STL.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: