The code below demonstrates the Idea of constructor overloading. However, the programmer forgot to add the main function to execute the code. Produce the main function and create three object variables, one for each of the constructors and initialize them. By using the display() method, write the necessary codes to display the output of the each constructor.  #include using namespace std; class CHELSEA { private: int x,y; public: CHELSEA () //constructor 1 with no arguments { x = y = 0; } CHELSEA(int a) //constructor 2 with one argument { x = y = a; } CHELSEA(int a,int b) //constructor 3 with two argument { x = a; 4 y = b; } void display() { cout << "x = " << x << " and " << "y = " << y << endl; } };

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 8SA: Consider the definition of the following class: (1, 2, 3, 5, 7) a. Give the line number...
icon
Related questions
Question

The code below demonstrates the Idea of constructor overloading. However, the programmer forgot to add the main function to execute the code. Produce the main function and create three object variables, one for each of the constructors and initialize them. By using the display() method, write the necessary codes to display the output of the each constructor. 

#include <iostream> using namespace std; class CHELSEA { private: int x,y; public: CHELSEA () //constructor 1 with no arguments { x = y = 0; } CHELSEA(int a) //constructor 2 with one argument { x = y = a; } CHELSEA(int a,int b) //constructor 3 with two argument { x = a;



4

y = b; } void display() { cout << "x = " << x << " and " << "y = " << y << endl; } };

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage