Advanced Generics and Casts
If a man empties his purse into his head, no one can take it from him.
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 ...