Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Complete the declaration of the copy assignment operator for Dealership. Ex: If the input is 2 8 0 . 5 0 , then the output
Complete the declaration of the copy assignment operator for Dealership.
Ex: If the input is then the output is:
Selfassignment not permitted
dealership: $ daily profit
dealershipCopy: $ daily profit
Destructor called
Destructor called#include
The Code is:
#include
#include
using namespace std;
class Dealership
public:
Dealership;
~Dealership;
void setDailyProfitdouble newDailyProfit;
void Print const;
Dealership& operatorconst Dealership& dealershipToCopy;
private:
double dailyProfit;
;
Dealership::Dealership
dailyProfit new double;
dailyProfit ;
Dealership::~Dealership
cout "Destructor called" endl;
delete dailyProfit;
Your code goes here
if this &dealershipToCopy
delete dailyProfit;
dailyProfit new double;
dailyProfit dealershipToCopydailyProfit;
else
cout "Selfassignment not permitted" endl;
return this;
void Dealership::setDailyProfitdouble newDailyProfit
dailyProfit newDailyProfit;
void Dealership::Print const
cout fixed setprecision$dailyProfit daily profit" endl;
int main
double dailyProfit;
Dealership dealership;
Dealership dealershipCopy;
cin dailyProfit;
dealership.setDailyProfitdailyProfit;
dealership dealership; Test selfassignment
dealershipCopy dealership;
dealership.setDailyProfit;
cout "dealership: ;
dealership.Print;
cout "dealershipCopy: ;
dealershipCopy.Print;
return ;
Step 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