In C++, a derived class's method only overrides the base class's method if their declarations match (I say "match," but I'm not sure what the formal term is).
That is, all arguments must be of the same type, with the same const qualification.
If there are any mismatches, the derived class's method hides all methods with the same name rather than overriding.
This is what the "ERROR" in your image is attempting to convey.
So, in that image, / overrides in a comment is incorrect and misleading.
Yes, many C++ instructors are unaware of these somewhat esoteric details.
Furthermore, if you want to override, your base class's method must be virtual; otherwise, polymorphism will not work.
. We could also say that the derived-class method hides the base-class method if it wasn't virtual.
The part about hiding, on the other hand, has almost no meaning here; what this term really means is that you're not in charge.
Furthermore, overloading is the presence of multiple methods with the same name but different signatures, as you may have noticed. To be useful, they must all be present in the derived class; otherwise, they will be hidden if the derived class only has one method, fa1, and the other fa1 are in the base. There is, however, a syntax sugar that "copies" all fa1 from base to derived, removing all the hidden semantics:
class A
{
public:
void fa1();
void fa1(int);
};
class B: public A
{
public:
using A::fa1;
void fa1(int, int);
};
...
B b;
b.fa1(); // calls A::fa1()
b.fa1(4); // calls A::fa1(int)
b.fa1(4, 8); // calls B::fa1(int, int)
The part about hiding is rarely, if ever, useful. When overriding, you should tell this to your compiler - use the override keyword for that. The compiler will then check that your code works as you intended.
class A
{
public:
virtual void fa1(int) {}
void fa2(int) {}
};
class B: public A
{
public:
void fa1(int) override {} // OK
void fa1() override {} // ERROR: doesn't really override - different signature
void fa2(int) override {} // ERROR: doesn't really override - not virtual in base
};