[Solved] CS_1C Homework 4-Friend Functions & Operator Overloading

$25

File Name: CS_1C_Homework_4-Friend_Functions_&_Operator_Overloading.zip
File Size: 527.52 KB

SKU: [Solved] CS_1C Homework 4-Friend Functions & Operator Overloading Category: Tag:
5/5 - (1 vote)

Using HW03

  1. Write and test a friend function that checks to see if the phone number of a C1SCEmployee object is equal to the phone number of a Programmer object. Test equal and not equal scenarios. (You will need to call your ChangePhoneNumber method)
  2. Overload the equality operator to see if the phone number of two C1SCEmployees are the same. Test equal and not equal scenarios. (You will need to call your ChangePhoneNumber method)
  3. Write an addition member function that adds an integer to a CS1Cemployees age (make sure the integer is a passed parameter). The output should state how many years were added to the age.
  4. Overload the addition operator to add a constant to a

CS1Cemployees age. For example: StarC1SCEmployee = StarC1SCEmployee + 2. The output should state how many years were added to the age.

  1. Overload << and >> operators to read in a CS1Cemployee object

(e.g. cin >> myEmployee and cout << myEmployee)

Your output should be easy to follow and contain output only from hw04.

Extra Credit [+5 pts]

Overload the pre & post increment operators to increment an

CS1Cemployees age. Test pre/post increment operations. Output HW04 Friend Functions & Operator Overloading [50 pts]

the values of CS1Cemployee objects before and after pre/post increment operations as well as after assignment takes place.

Demonstrate how pre/post increment operators are different.

Which overloaded operator incurs the most overhead?

Use the command script to capture your interaction compiling and running the program, including all operations, as shown below:

CS1C Fall 2018 TTH HW04 50pts Due: Tu 9/11/2018

[email protected] ~/cs1c/hw/04 $ script hw04.scr Script started, file is hw04.scr [email protected] ~/cs1c/hw/04 $ date

[email protected] ~/cs1c/hw/04 $ ls -l

[email protected] ~/cs1c/hw/04 $ make all

[email protected] ~/cs1c/hw/04 $ ls -l

[email protected] ~/cs1c/hw/04 $ ./hw04

// print out test results for the friend & member functions from steps 1, 3

// print out test results for the overloaded operators from steps 2, 4, 5

[email protected] ~/cs1c/hw/04 $ exit Script done, file is hw04.scr

[email protected] ~/cs1c/hw/04 $ make tar

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CS_1C Homework 4-Friend Functions & Operator Overloading
$25