I have a class structure looking like this:
class A {
public:
A();
virtual void doSomething() {
qDebug() << "Hello from class A";
}
};
class B : public A {
public:
B();
void doSomething() {
qDebug() << "Hello from class B";
}
};
class C : public A {
public:
C();
void doSomething() {
qDebug() << "Hello from class C";
}
};
Somewhere else I have a method like this:
void doSomethingElse(const A argument = A()) {
argument.doSomething();
}
Everytime doSomethingElse
is called I get the "Hello from class A" output, even if I pass an instance of class B or C as the argument.
What am I doing wrong here?