No, itβs actually not possible to override the definition in the parent (at least when it comes to C ++, βoverridingβ is usually reserved specifically for invoking virtual functions). Instead, defining a function with the same name in the child class simply hides the function in the parent that has the same name (that is, in the context of the child, searching for that name will only find the function in the child, and not in the parent).
If you want (and the functions have different signatures), you can also get the functions in both the parent and the child, processed as overloaded, so the call will try to call depending on which matches are better:
struct parent { void func1(char) {} }; struct child : public parent { void func1(long) { } using parent::func1; };
Now you get:
child c; c.func1('a'); // calls parent::func1 c.func1(123L); // calls child::func1
This is another third type of behavior, although it differs from having a virtual function or having a function in a child that hides it in the parent.
Using a virtual function, the choice of the called function is based on the dynamic type, so if you have a pointer / reference to the base class, the called function depends on whether it refers to a database object or a derived class.
When you hide a function, the called function is based on a static type, so if you call it with a pointer / reference to the base, it calls the base function, even if it actually refers to an object of the derived class. If, however, you use a pointer or a reference to (or directly use an instance of) the derived class, it will call the function in the derived class.
Using the using statement, you get an overload of functions, so when you call a function (in the context of a derived class), the called function is based on which function signature best matches the parameter (s) you are passing.