Question:Consider the sample code given below and answer the question that follows.
class Shape
{
public:
virtual void draw() = 0;
};

class Rectangle: public Shape
{
public:
void draw()
{
// Code to draw rectangle
}
//Some more member functions.....
};

class Circle : public Shape
{
public:
void draw()
{
// Code to draw circle
}
//Some more member functions.....
};

int main()
{
Shape objShape;
objShape.draw();
}
What happens if the above program is compiled and executed? 

A Object objShape of Shape class will be created 

B A compile time error will be generated because you cannot declare Shape objects 

C A compile time error will be generated because you cannot call draw function of class 'Shape' 

D A compile time error will be generated because the derived class's draw() function cannot override the base class draw() function 

E None 

+ Answer
+ Report
Total Preview: 11298

Copyright © 2024. Powered by Intellect Software Ltd