CHAPTER 16
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 ...
Get C++ 2013 for C# Developers,Second 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.