There are three classes should inherit two overloaded functions here.
The problem is that derived classes call one function from second only
against the class declaration despite of the overloading params.
They're not overridden, they're hidden. When you create a function with the same name but different parameters in a child class, it "hides" the parent class functions.
If you want them to be un-hidden, you need the usind directive.
Also main() should return an int.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
class a_class {
public:
void f(double ) {printf("Class A (double)\n");}
void f(unsignedlong) {printf("Class A (unsigned long)\n");}
};
class b_class: public a_class {
public:
using a_class::f; // <- THIS
void f(unsignedlong) {printf("Class B (unsigned long)\n");}
};
class c_class : public b_class {
public:
using b_class::f; // <-- AND THIS
void f(double) {printf("Class C (double)\n");}
};
Also, your 3rd set of f calls was probably supposed to be c.f()?
Well, what do you not understand about classes? You used them yourself in your own code, so I assume you made the code yourself and didn't just copy-paste someone else's code.
The code that was given to you was meant as example code, because it was an example of code that was correct.