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 16

image

Advanced Generics and Casts

If a man empties his purse into his head, no one can take it from him.

—Benjamin Franklin

In Chapter 14, we saw how generic types descended from System::Object and were able to access all of the System::Object methods. In addition, we found that we could use the collection classes such as Stack<T> and Queue<T> to maintain type-safe lists of generic objects. In this chapter, we learn how to use constraints, cast operators, and runtime type identification to write generic classes and functions that do more than gather handles to objects descended from System::Object; these classes and functions will act ...

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