Is it function overloading or overriding or something else ? ( hello function )
class A {
public:
void hello(int x) { cout << "A" << endl; }
};
class B : public A {
public:
void hello() { cout << "B" << endl; }
};
void main() {
B obj;
obj.hello();
}
It’s neither, it’s function hiding.
Declaring a non-virtual function with the same name (even if the signature is different) in a derived class hides the base class implementation completely.
To still have access to
A::hello, you can do the following:Overriding:
Overloading: