Posts

Showing posts from October, 2014

Method overloading,overriding and need of it,Concept of object

Image
Method overloading : Let me get this straight,method overloading simply means same method with different parameters either of different data-type or different parameter size.Return type must be same. Here's the example: Valid overloading of methods: void foo():nothing in the parameters list void foo(int num):one  parameter of type int void foo(int a,int b):two parameters of type int void foo(float a,float b): two parameters of type float void foo(int num,float tot): two parameters of type float and int In-Valid overloading of methods: If the parameters of the at-least one method is exactly the same invalid overloading. Need of overloading methods?? Method overloading is needed because there are situations where a single method have to do several kind of work.Suppose there is a method name calc_area that calculates area of different figures such as: Circle:single parameters with float value  calc_area(float r). Triangle:Two parameters(base and ht,) with float va