Chapter 5

Creating Classes with Templates

In This Chapter

arrow Creating class templates

arrow Using parameters in templates

arrow Deriving with templates

arrow Creating function templates

If C++ programming has any big secret, it would have to be templates. Templates seem to be the topic that beginning programmers strive to understand because they’ve heard about them and seem to think that templates are the big wall over which they must climb to ultimately become The C++ Guru.

We can’t say whether understanding templates will make you a C++ guru (we like to think that it will!), but we can say that it will open your abilities to a whole world out there, primarily because the entire Standard C++ Library is built around templates. Further, understanding templates can help you understand all that cryptic code that you see other people posting on the Internet. (And it will help you realize that it didn’t have to be so cryptic! Simplify, simplify, we always say!)

So, in this chapter, we show you how to use application templates in C++.

Templates have an interesting history. Back when people started building ...

Get C++ All-in-One For Dummies, 3rd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.