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
};