O'Reilly logo

C++ 2013 for C# Developers,Second Edition by Dean C. Wills

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

CHAPTER 15

image

Introduction to Templates

Even for practical purposes, theory generally turns out the most important thing in the end.

—Oliver Wendell Holmes

In the previous chapter, we saw what you could do with C++/CLI generics. In this chapter, I will introduce templates, which are similar to generics in many ways and different in many others.

Comparison with Generics

Templates and generics both allow you to create functions and classes that implement functionality for multiple types. We can approach this in one of two ways:

  • Write code that is decoupled from the type of data that is being acted upon. The code only implements algorithms that ...

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