Reference solution
One correct implementation. Alternative approaches that satisfy the constraints are equally valid — the reviewer judges behaviour, not style.
#include <iostream>
using namespace std;
class Animal {
public:
void speak() const { cout << "sound" << '\n'; }
};
class Dog : public Animal {
public:
void bark() const { cout << "bark" << '\n'; }
};
int main() {
Dog d;
d.speak();
d.bark();
return 0;
}