Over Loading and Overriding
In a class if two method is having the same name and different signature,its known as overloading in Object oriented concepts.
For eg Take the case of a Shape Class. having a method with a name DrawShape();
This method has two definitins with different parameters.
public void DrawShape(int x1, int y1,int x2,int y2)
{
// draw a rectangle.
}
public void DrawShape(int x1,int y1)
{
// draw aline.
}
Overriding means, to give a specific definition by the derived class for a method implemented in the base class.
For eg.
Class Rectangle
{
publc void DrawRectangle()
{
// this method will draw a rectangle.
}
}
Class RoundRectangle : Rectanlge
{
public void DrawRectangle()
{
//Here the DrawRectangle() method is overridden in the
// derived class to draw a specific implementation to the
//derived class, i.e to draw a rectangle with rounded corner.
}
}