What is Inheritance?
Inheritance is one of the primary concepts of object-oriented programming, and is when one object (a child) extends another object (the parent). By extending the parent object, the child object inherits the properties and methods of the parent object.
By using the concept of inheritance you can create a hierarchy of objects, beginning with general things and progressing to very specific objects. Let's use a real-world example, and envisage an e-commerce application.
Let's imagine that initially our online store sells only books, and as such we only have one single product object, Book.cfc
. This component contains the relevant properties accessor and mutator methods to read and write our information relating to our book products.
The UML diagram of the object could look something like this:
At the moment, this Book object is perfectly suited for our application. It contains exactly the right properties we need to provide information about our books. It would also be...