0
does overriding a method results in overriding of the over loaded methods too ?
4 odpowiedzi
+ 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.
+ 1
The answer is no, the other overloading methods aren't overriden.
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);
}
0
how can u justify your answer wit the above code ??