Lecture 7 Classes Inheritance and Type Compatibility
Lecture 7 Classes Inheritance and Type Compatibility
compatibility
Classes and Data Types
• Each new class constitutes a new type of data.
• Each object constructed on the basis of such a class is like a value of
the new type.
Object Compatibility
• Any two objects may (or may not) be compatible in the sense of their
types.
Example: Cat and Dog Classes
#include <iostream> int main() {
Cat *a_cat = new Cat();
using namespace std; Dog *a_dog = new Dog();