0% found this document useful (0 votes)
5 views2 pages

Return Object

The document outlines the implementation of a Customer class to manage customer information, including private member variables for name, id, and balance. It specifies the creation of a constructor, a display function to print customer details, and a function to update customer information by returning a new Customer object with updated values. Additionally, it includes instructions for creating an initial Customer object and displaying the details of a newly created Customer object in the main function.

Uploaded by

Suhaib Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Return Object

The document outlines the implementation of a Customer class to manage customer information, including private member variables for name, id, and balance. It specifies the creation of a constructor, a display function to print customer details, and a function to update customer information by returning a new Customer object with updated values. Additionally, it includes instructions for creating an initial Customer object and displaying the details of a newly created Customer object in the main function.

Uploaded by

Suhaib Ahmad
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Objective:

You will implement a simple class for managing customer information. You will create a
Customer class with various member functions, and practice returning objects by value from a
function. The goal is to return a new Customer object with updated information based on input
values.

Instructions:

1. Create a Customer class:

o The Customer class should have the following private member variables:

▪ name (string)

▪ id (integer)

▪ balance (double)

2. Constructor:

o Write a constructor to initialize the name, id, and balance when a Customer
object is created.

3. Display Function:

o Implement a member function display() that prints the name, id, and balance of
the customer to the console.

4. Create a Function to Update Customer Information:

o Implement a member function createCustomerWithUpdatedBalance(string


newName, int newId, double newBalance) that:

▪ Takes parameters newName, newId, and newBalance.

▪ Creates and returns a new Customer object with these updated values.

▪ This function should return the new Customer object by value.

5. In the main() function:

o Create an initial Customer object, e.g., "Alice", 1001, 1000.0.

o Call the createCustomerWithUpdatedBalance function to create a new Customer


object with a different name, ID, and balance.
o Print the details of the new Customer object by calling its display() method.

You might also like