Question: Topics: Friend functions Copy constructor Overloaded operators The anti AI constraints: Any C + + terms, constructs and / or methodologies covered in CIS 2

Topics:
Friend functions
Copy constructor
Overloaded operators
The anti AI constraints:
Any C++ terms, constructs and/or methodologies covered in CIS 22A are available for your use.
You may only use additional C++ constructs or terms covered in lecture or zyBook (ebook) reading
assignments found in In modules 1,2,3,4,5,6 and 7. Deviation from these constraints lose points.
Utilizing your Lab 2 code as a starting point, move both the input and output functions declarations
outside the class. They will no longer be able to directly access your private data (youll need to use
both mutators and accessors for private data access).
We have added a new load type, Combo Flat. Your code will need to handle this as a string. Combo Flat
abbreviations for the 737 are CFE, CFK and CFM.
Create your objects on the stack (not on the heap).
Add a friend function, kilotopound, which will convert kilograms to pounds. Change your weight
mutator to ask whether weight is input in kilograms or pounds. If it is kilograms, call the friend function
kilotopound to convert it to pounds and return pounds. There are 2.2 pounds in one kilogram.
Add a copy constructor.
Create an object on the stack with the following information (or appropriate data of your choice):
uld Container
abbreviation - AYK
uldid AYK68943IB
aircraft -737
weight 1654 Kilograms
destination PDX
Copy the object using a copy constructor. Output the contents of both objects. Your code must
include both the friend function and the copy constructor.
Now, add an overloaded operator == which will be used to compare two objects to see if they are
equal. C++ does not allow a direct comparison of two objects, so we use an overloaded operator and
associated code to perform the comparison. For our purposes, two objects are equal if their
abbreviation and uldid are the same.
Create an object (call it unit1) and load it with this data:
uld Pallet
abbreviation PAG
uldid PAG32597IB
aircraft -737
weight 3321 Pounds
destination SEA
Make a copy of unit1 called unit2 utilizing the copy constructor.
Create a default object called unit3.
Test your overloaded == operator with code like this in main:
if (unit1== unit2)
cout <<"
unit1 is the same as unit2
";
else
cout <<"
unit1 is not the same as unit2
";
if (unit2== unit3)
cout <<"
unit2 is the same as unit3
";
else
cout <<"
unit2 is not the same as unit3
"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!