September 2014
Intermediate to advanced
396 pages
7h 58m
English
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 ...
Read now
Unlock full access