4
Reply

Why we should go for Overriding ?

Naresh Babu Gopavaram

Naresh Babu Gopavaram

Feb 28 2011 9:39 AM
1.8k

why overriding  in the following  situation?

 

suppose i have like this

 

 

class a

{

public virtual int add(int x ,int y)

{

retunt x+y;

}

 

}

 

class a:b

{

public Override int add(int x ,int y)

{

/// some logic here

}

 

}

in the above situation i can get the child and parent  add() method by creating object on them then why i go for Overriding ?

 

is there is any performance issues are there ?like memory allocation...etc?

 

Plz help me ...........


Answers (4)