O'Reilly logo

SAMS Teach Yourself C++ in 10 Minutes SECOND EDITION by Jesse Liberty

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Templates Versus Generic Classes

Templates generate code in your program each time they are instantiated, so they make the program larger than generic classes. However, generic classes (which leverage class polymorphism) have to use virtual functions, which makes each function call slightly slower.

In any event, you should not let performance drive your decision between templates and class polymorphism unless the problems are severe and you can determine through performance measurements that they are the result of using or not using templates.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required