Naresh Babu Gopavaram

Naresh Babu Gopavaram

  • 1.5k
  • 248
  • 248.9k

Why we should go for Overriding ?

Feb 28 2011 9:39 AM

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)