0

does overriding a method results in overriding of the over loaded methods too ?

1st Sep 2016, 11:59 AM
Vjmsd
Vjmsd - avatar
4 Answers
+ 1
overloading and overwriting are different concepts. the first occurs when there are two or more functions with the same name but varying parameter types in the same scope. c++ will determine which of the functions has to bei called using the supplied parameters' types. the other occurs in inheritance and polymorphism, both pillars of object oriented programming. here, overriding means extending or replacing inherited functionality/algorithm from the superclass. of course, if there are multiple functions with the same name in the superclass, c++ will select the one whose parameters match the call or fail.
1st Sep 2016, 10:42 PM
René Schindhelm
René Schindhelm - avatar
+ 1
The answer is no, the other overloading methods aren't overriden.
8th Sep 2016, 12:08 AM
Zen
Zen - avatar
0
#include<iostream> using namespace std; class a{ public: int f(){cout<<3;} int f(int a){cout<<a;} }; class b:public a { public: int f(){cout<<5;} }; int main() { b obj; obj.f(7); }
2nd Sep 2016, 12:57 PM
Vjmsd
Vjmsd - avatar
0
how can u justify your answer wit the above code ??
2nd Sep 2016, 12:58 PM
Vjmsd
Vjmsd - avatar