Inheritance is a relationship between a base and its derived class.
- Base class
- Also called the Parent class
- This can be reusable by being inherited to the child classes
- Derived class
- The child class inheriting its parent
- Provides resubility of existing implementation
- Polymorphism, will see more on dedicated post that helps the same
public string make;
{
//Different ways, its implementation
}
}
{
public string model;
}
{
//implementation
}
//implementation
}
- It is a half defined class, becuase it can have an abstract implementation and hence no instance can be created of abstract classes
- This is helpful to create a base class to provide primary implementation to be followed for their child classes
- All the abstract methods declaration requires its child classes do have an implementation of the same
- Virtual Methods helps child classes to Override the same and change their own logic
- It's a contract
- classes that inherite the interface must have to implement all the methods from that Interface
- Instance creation is not allowed
- Helps to standardize coding practice across multiple classes
- if parent and child classes share the same name for their methods, the new modifier at method definition helps to hide the base class implementation