|
-
October 15th, 2011, 01:17 PM
#11
Re: difference between polymorphism and overloading
 Originally Posted by laserlight
Overloading is polymorphism: ad-hoc polymorphism; what you stated is supertype/subtype polymorphism.
Code:
class Cbase
{
void Func();
void Func(int); //Overloading
virtual void PolyFunc();
};
class CDerived : public CBase
{
void PolyFunc();
};
Func is overloaded. PolyFunc is, or can be, polymorphic. It's not really the same concept. Overloading gives a different signature to a function so you can call the function with diffferent argument types and numbers. In simplistic terms, polymorphism means that the function will be called for the correct class when accessed through a base class pointer.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|