May 2002
Beginner
320 pages
6h 18m
English
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.
Read now
Unlock full access