Question
Please help with c++ here is 3.1. Please utilizing #include #include using namespace std; // naming the class as Lab and defining it with required
Please help with c++
here is 3.1. Please utilizing
#include
#include
using namespace std;
// naming the class as Lab and defining it with required data members
class Lab
{
private:
string uId;
string abbreviation;
string uIdid;
int aircraft;
float weight;
string destination;
public:
// default constructor
Lab()
{
uId = "";
abbreviation = "";
uIdid = "";
aircraft = 0;
weight = 0;
destination = "";
}
// parameterized constructor
Lab(string uid, string abb, string uidid, int ac, float w, string d)
{
uId = uid;
abbreviation = abb;
uIdid = uidid;
aircraft = ac;
weight = w;
destination = d;
weightMutator();
}
// copy constructor
Lab(const Lab& l1)
{
uId = l1.uId;
abbreviation = l1.abbreviation;
uIdid = l1.uIdid;
aircraft = l1.aircraft;
weight = l1.weight;
destination = l1.destination;
}
// updating the weightMutator function as required and calling it in parameterized constructor once
void weightMutator()
{
string w;
cout
cin>>w;
transform(w.begin(), w.end(), w.begin(), ::tolower);
if(w == "kg" || w == "kilograms")
{
weight = kilotopound(*this);
}
}
// function to output the content of object
void printData()
{
cout
cout
cout
cout
cout
cout
}
// declaring the friend function kilotopound
friend float kilotopound(Lab l1);
};
// converting the weight from kilograms to pounds
float kilotopound(Lab l1)
{
return l1.weight*2.2;
}
int main()
{
string uId;
string abbreviation;
string uIdid;
int aircraft;
float weight;
string destination;
// taking data for demonstration of friend function and making object and displaying its contents
cout
cout
cin>>uId;
cout
cin>>abbreviation;
cout
cin>>uIdid;
cout
cin>>aircraft;
cout
cin>>weight;
cout
cin>>destination;
Lab l(uId, abbreviation, uIdid, aircraft, weight, destination);
cout
l.printData();
// taking data for demonstration of copy constructor and making two objects
// one from given data and one using copy constructor and displaying both objects
cout
cout
cin>>uId;
cout
cin>>abbreviation;
cout
cin>>uIdid;
cout
cin>>aircraft;
cout
cin>>weight;
cout
cin>>destination;
Lab l1(uId, abbreviation, uIdid, aircraft, weight, destination);
Lab l2(l1);
cout
l1.printData();
cout
l2.printData();
return 0; }
Lab 3.2 Utilizing Lab 3.1 code, add a copy constructor. Create an object on the stack using the following data: uld - Container abbreviation - ABB uldid - ABB315451B aircraft - 737 weight - 1156 destination - BUR Copy the first object using a copy constructor. Output the contents of both objectsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started