Question: Consider the code snippet below, which uses the base - class Question and the derived class ChoiceQuestion: Question * quiz [ 2 ] ; quiz

Consider the code snippet below, which uses the base-class Question and the derived class ChoiceQuestion:
Question* quiz[2];
quiz[0]= new Question;
quiz[0]->set_text("Who was the inventor of C++?");
quiz[0]->set_answer("Bjarne Stroustrup");
ChoiceQuestion* cq_pointer = new ChoiceQuestion;
cq_pointer->set_text("In which country was the inventor of C++ born?");
cq_pointer->add_choice("Australia", false);
...
quiz[1]= cq_pointer;
Why is the last line of code not a type mismatch?

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!