Suppose I have a 2 classes:
struct a
{
void test();
};
struct b
{
void test();
};
Now let’s inherit from those classes:
class c : public a, public b
{
};
Calling c::test() will generate an error, since class a and class b have the same function void test(), now my question:
Is it possible to inherit those (non-virtual!) functions, and when c::test() is called both are executed?
To do this, you need to implement
void test()inc, and call both methods. There’s no automatic way to do it.However, I would strongly discourage you from reimplementing non-virtual functions in derived classes. The problem is that the following would quietly call different functions, even though they operate on the same object: