In this article we will cover following points
2. Use of Inheritance
3. Points to remember about inheritance
4. Derived Class Communication with Base Class
5. Methods in Base class & Derived classes
Characteristics or Pillars of Object Oriented Programming
1. Inheritance enables to create new classes that reuse, extend and modify the behaviour that
is defined in another classes.
2. The class whose members are inherited is called the base class, and the class that inherits
those members is called the derived class.
3. A derived class can have only one direct base class.
Use of Inheritance
1. Ideally a derived class is a specialization of the base class, which means the derived class
extends the functionality of the base class.
Points to remember
1. C# supports only single class inheritance.
2. But C# supports multiple interface inheritance.
3. Base class or parent class constructor executes before derived or child class constructor.
4. Derived class implicitly gains all the members of the base class, except for its constructors
5. Derived class has access to the public, protected, internal, and protected internal members
of base class. Derived class inherits the private members of a base class but it cannot access
6. Base classes are automatically instantiated before derived classes.
Derived Class Communication with Base Class
1. Using the base keyword, you can access any of a base class public or protected class
2. Alternatively Base class members can be accessed through an explicit cast.
Methods in Base class & Derived classes
1. If base class declares a method as virtual, derived class can override the method with its own
2. Derived class can hide base class members by declaring members with the same name and
signature. The new keyword can be used to hide the base class members.