What is the difference between operator overloading and operator overriding?
Are they the same in inheritance and console program?
You can overload operator in C++ but not in Java. I wonder if you meant method overloading and method overriding? Method overloading is having two definitions for the same method signature. For example,
int sum(int var1, int var2)
{
return (var1+var2);
}
int sum(int var1, int var2, int var3)
{
return (var1+var2+var3);
}
In object oriented programming, you override (redefine) a function that is inherited from ascendant (base) class. In a class hierarchy, when a function (method) in a subclass has the same name and type signature as a method in its superclass, then the method in the subclass is said to override the method in the superclass.