CMPSC 32 Lecture Notes - Lecture 10: Subtyping, Liskov Substitution Principle
Document Summary
Object-based-programming = using objects for encapsulation, but not using subclasses. Could create objects directly or use classes and instantiate (using new operator) Non-obp can simulate this by, for example, having a default first parameter. Templates/generics are not specifically a part of object-oriented. New classes can be declared to be children of parent class. Derived class automatically gets (inherits) all members (data and methods) of base class. Can instantiate those classes, design their own small hierarchies. Possible to inherit from more than one class. Class can inherit code from only one parent. Can implement any number of pure virtual classes in c++ Use (function) overloading to do different things to different types. Use template to do the same thing to different types. Instance of derived class is also considered a valid instance of base class. Meaning of a message depends on the runtime (dynamic) type of the receiver.