Assignment


Write a C++ program that will create a class named Computer. This class will have 4 data members
1. Vendor
2. CPU
3. Hard disk
4. RAM

You are required to write a default and a parameterized constructor for this class. Also write getter and setter functions for each data member of the class.

In the default constructor, you will initialize all the data members with default values. The message “Default constructor called…” should be displayed whenever an object is created using default constructor.

In parameterized constructor, you will initialize all the data members with the values passed to it as arguments. You are required to use setter functions inside parameterized constructor to initialize the data members. The message “Parameterized constructor called…” should be displayed whenever an object is created with parameterized constructor.

In the main() function, create 2 objects (1 using default and 1 using parameterized constructor) and display the values of data members of both objects using getter functions.

Sample output for the program is shown below:

Sponsored Links