Introduction to OOP | Chapter 19: Container Classes : | next | previous | audio | real | text |
var stack : TStack; aCat : TCat; aDog : TDog; begin // create a stack that can hold only TCat values stack := TStack.Create (TCat); stack.push (aCat); // ok stack.push (aDog); // will raise exception ... endAllows typing errors to be caught on insertion, but uses more space and time.