Consider the following code:
class Animal
{
private:
int weight;
public:
Animal()
{
}
virtual void Speak()
{
cout << "Animal speaking";
}
};
class Snake : public Animal
{
private:
int length;
public:
Snake()
{
}
void Speak()
{
cout << "Snake speaking\r\n";
}
};
int main()
{
Animal *array = new Snake[10];
for (int index= 0; index < 10; index++)
{
array->Speak();
array++;
}
return 0;
}
What happens when the above code is compiled and executed?
Correct Answer: The code will crash at runtime
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More C++ MCQ Questions