9
What will be the output of the program?
#include <iostream>
using namespace std;
class Animal {
public:
virtual const char *sound() const = 0;
virtual ~Animal() {}
};
class Dog : public Animal { public: const char *sound() const override { return "woof"; } };
class Cat : public Animal { public: const char *sound() const override { return "meow"; } };
int main() {
Dog d; Cat c;
const Animal *z[] = {&d, &c};
for (auto a : z) cout << a->sound() << " ";
cout << endl;
return 0;
}Easy