Which figure will be drawn as a result of the following code execution?
struct Base {
   virtual void draw( Color Col = RED ) { 
      // draws square of Col color

struct Derived : Base {
   virtual void draw( Color Col = GREEN ) {
      // draws circle of Col color

// ... polymorphic method call
Base * B = new Derived;
B -> draw();
Never redefine an inherited default parameter value, because default parameter values are statically bound, while virtual functions — the only functions you should be overriding — are dynamically bound.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Sign Up Now
or Subscribe for future quizzes