Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

Difference between method overriding and overloading

This is a discussion on Difference between method overriding and overloading within the OOPS forums, part of the Software Development category; Originally Posted by nancyphilips Is the concept of method overriding different from the concept of overloading. If so how they both differ. Function Overriding: In a child class, redefining the ...

Go Back   Geeks Talk > Software Development > OOPS
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read

OOPS Object-Oriented Programming Concepts

Reply

 

LinkBack Thread Tools Display Modes
  #21 (permalink)  
Old 05-25-2008
Junior Member
 
Join Date: Jun 2007
Location: Redmond, WA, USA
Posts: 18
Thanks: 2
Thanked 6 Times in 5 Posts
SomGollakota is on a distinguished road
Re: Difference between method overriding and overloading

Quote:
Originally Posted by nancyphilips View Post
Is the concept of method overriding different from the concept of overloading. If so how they both differ.
Function Overriding: In a child class, redefining the default behavior of an inherited function (default behavior of an inherited function is the behavior defined in the parent class for this function). For example,
class MyParent:
{
virtual Func() { print "Hello World"; }
};
class MyChild : public MyParent
{ // Default behavior of Func is (parent supplied) "Hello World"
//Redefining parent supplied behavior
Func() { Calculate equations; print equations;}
}
---------------------
Function Overloading: Has nothing to do with inheritance. This is the ability that the programming language offers you, by which you can reuse the lable name of the function to perform different tasks at different times. For example:
class MyClass
{
int MyOLFunction () { print "Hello World"; return 0;}
int MyOLFunction (int x) { print "Hello World" x number of times; return 0;}
int MyOLFunction (char a) { print "Hello World"; print a; return 0;}

//Note: The following are not function overriding, and will generate compile time error
long MyOLFunction () { print "Hello World"; return 0;} // Error
char MyOLFunction () { print "Hello World"; return 0;} // Error
};
Reply With Quote
Sponsored Links
  #22 (permalink)  
Old 05-29-2008
Junior Member
 
Join Date: May 2008
Location: Chandigarh
Posts: 2
Thanks: 0
Thanked 1 Time in 1 Post
Ask2gk is on a distinguished road
Re: Difference between method overriding and overloading

Overriding means modifying or enhancing the method implementation in derived class.
Overloading means class have more than one method having same name but different implementation or different number of input parameters with different return type.
Reply With Quote
  #23 (permalink)  
Old 10-26-2008
Contributing Member
 
Join Date: Oct 2008
Location: tamilnadu,india
Posts: 74
Thanks: 2
Thanked 6 Times in 6 Posts
rakesh trichy is on a distinguished road
Re: Difference between method overriding and overloading

* Overloading deals with multiple methods in the same class with the same name but different signatures

* Overriding deals with two methods, one in a parent class and one in a child class, that have the same signature

* Overloading lets you define a similar operation in different ways for different data

* Overriding lets you define a similar operation in different ways for different object types
Reply With Quote
  #24 (permalink)  
Old 11-19-2008
Junior Member
 
Join Date: Nov 2008
Location: chennai
Posts: 3
Thanks: 0
Thanked 2 Times in 2 Posts
pvram is on a distinguished road
Re: Difference between method overriding and overloading

when ever we want code refinement(means some changes in method body) then that time we r using overloding

when ever we want cod replacement(means totally changes body) then that time we r useing overriding
Reply With Quote
  #25 (permalink)  
Old 09-11-2009
Junior Member
 
Join Date: Sep 2009
Location: india
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
kohisathya_07 is on a distinguished road
Re: define primitive varible?

i need the answer for the title
Reply With Quote
  #26 (permalink)  
Old 3 Weeks Ago
Junior Member
 
Join Date: Oct 2007
Location: jaipur
Posts: 5
Thanks: 2
Thanked 1 Time in 1 Post
devgan is on a distinguished road
Re: Difference between method overriding and overloading

differences are as follows:
OVERLOADED OVERRIDING
1.)arguments- can change must not change

2.)exceptions-can change cant change except for covariant returns

3.)invocation-reference type determines which overloaded version is selected at compile time .the actual method tht is invoked is still svirtual method invocation that happens at runtime but the compiler will already know the signature of the method to be invoked .so at the runtime the argument match will already have been nailed down
but in overriding object type determines which methjod is selcted happens at runtime
Reply With Quote
Reply

  Geeks Talk > Software Development > OOPS

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -4. The time now is 04:05 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2009 GeekInterview.com. All Rights Reserved