1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
attashe74 [19]
3 years ago
15

Write a copy assignment operator for CarCounter that assigns objToCopy.carCount to the new objects's carCount, then returns *thi

s. Sample output for the given program:
Cars counted: 12
#include
using namespace std;

class CarCounter {
public:
CarCounter();
CarCounter& operator=(const CarCounter& objToCopy);
void SetCarCount(const int setVal) {
carCount = setVal;
}
int GetCarCount() const {
return carCount;
}
private:
int carCount;
};

CarCounter::CarCounter() {
carCount = 0;
return;
}

// FIXME write copy assignment operator

/* Your solution goes here */

int main() {
CarCounter frontParkingLot;
CarCounter backParkingLot;

frontParkingLot.SetCarCount(12);
backParkingLot = frontParkingLot;

cout << "Cars counted: " << backParkingLot.GetCarCount();

return 0;
}
Computers and Technology
1 answer:
Olin [163]3 years ago
5 0

The following cose will be used to copy assignment operator for CarCounter

<u>Explanation:</u>

Complete Program:

#include <iostream>

using namespace std;

class CarCounter

{

public:

CarCounter();

CarCounter& operator=(const CarCounter& objToCopy);

void SetCarCount(const int setVal)

{

 carCount = setVal;

}

int GetCarCount() const

{

 return carCount;

}

private:

int carCount;

};

CarCounter::CarCounter()

{

carCount = 0;

return;

}

// FIXME write copy assignment operator

/* Your solution goes here */

CarCounter& CarCounter::operator=(const CarCounter& objToCopy)

{

if(this != &objToCopy)

 carCount = objToCopy.carCount;

return *this;

}

int main()

{

CarCounter frontParkingLot;

CarCounter backParkingLot;

frontParkingLot.SetCarCount(12);

backParkingLot = frontParkingLot;

cout << "Cars counted: " << backParkingLot.GetCarCount();

cout << endl << endl;

system("pause");

return 0;

}

You might be interested in
Un comerciante de régimen código para comprar mercancías gravadas a un comerciante de régimen simplificado precio de venta al pú
Genrish500 [490]

Answer:

El valor sin impuestos de las mercancías era de $1.512.605.

Explanation:

Dado que un comerciante de régimen código para comprar mercancías gravadas a un comerciante de régimen simplificado pagó un precio de venta al público 1.800.000 incluido el IVA tarifa general (19%), para determinar el valor de las mercancías sin el impuesto incluido se debe realizar el siguiente cálculo:

1.19 = 1.800.000

1 = X

1.800.000 / 1.19 = X

1.512.605 = X

Por lo tanto, el valor sin impuestos de las mercancías era de $1.512.605.

5 0
3 years ago
Which terms describes Benito Mussolini’s form of government
slega [8]
The political system that describes Benito Mussolini’s form of government would be totalitarian.Hope this answers the question:)
5 0
3 years ago
Read 2 more answers
Which category best represents: a student sends harassing emails to another student. The receiving student retaliates with a "fl
Dima020 [189]
It is considered C. cyber bullying
3 0
3 years ago
Read 2 more answers
Will robots take people's jobs? <br> write in complete sentence.
lilavasa [31]

Answer:

yes

Explanation:

yes because they already have them for old gun ships (which they still use) and they have made cars with them and more including bombing situations IED detinators they used in Afghanistan and in Iraq in 2011.

6 0
3 years ago
What is the purpose of HTML?
Scilla [17]
HTML is to give structure to the content of a web page. You can specify what links are part of the site's navigation, what sentences are headers and what blocks of text are paragraphs pertaining to those headers. Tables can present a data and establish the relationships of the data sets.
5 0
3 years ago
Other questions:
  • Write a program that accepts any number of homework scores ranging in value from 0 through
    10·1 answer
  • What udp port is used for i k e traffic from vpn client to server?
    14·1 answer
  • You also learn in class that one kilobyte of computer memory will hold about 2/3 of a page of typical text (without formatting).
    6·1 answer
  • A major difference between digital librarians and traditional librarians is that traditional librarians rarely work with people.
    15·2 answers
  • Write a program in c++ that plays a number guessing game with a Human user. The Human user will think of a number between 1 and
    7·2 answers
  • Make a webpage that shows news <br>​
    7·1 answer
  • Match the feature to its function.
    7·1 answer
  • Ill give brainliest if possible
    13·2 answers
  • How to count the total number of users from backend reactjs.
    6·1 answer
  • If you enter the search "genetically modified foods" in a database, the double quotes around the three words will:
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!