In general, Inheritance is a mechanism by which a subordinate or child class acquires the traits and qualities of a superordinate class or other derived classes. It also allows extra features like taking child class properties and using them in other derived classes. The syntax of classes is used to implement inheritance in Objective-C. A class also referred to as a superclass or parent class, can inherit the attributes and functions of other classes. The term “subclass” or “child class” refers to the class that inherits these attributes and methods.
The syntax for defining Subclass:
@interface SubclassName : SuperclassName //Name of the super class
// additional methods of the subclass
@end
A subclass inherits all of the instance variables, attributes, and methods of the superclass when it is defined. The subclass can also provide its own implementation of a method by overriding one from the superclass.
Sample Program: