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
Blababa [14]
3 years ago
7

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:

Computers and Technology
1 answer:
ollegr [7]3 years ago
3 0

Answer:

Here is the copy assignment operator for CarCounter:

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

carCount = objToCopy.carCount;

return *this;  }

The syntax for copy assignment operator is:

ClassName& ClassName :: operator= ( ClassName& object_name)

In the above chunk of code class name Is CarCounter and object name is objToCopy.

Assignment operator = is called which assigns objToCopy.carCount to the new objects's carCount.

This operator basically is called when an object which is already initialized is assigned a new value from another current object.

Then return *this returns the reference to the calling object

Explanation:

The complete program is:

#include <iostream>  //to use input output functions

using namespace std;   //to access objects like cin cout

class CarCounter {  //class name

public:  // public member functions of class CarCounter

CarCounter();  //constructor of CarCounter

CarCounter& operator=(const CarCounter& objToCopy);  //copy assignment operator for CarCounter

void SetCarCount(const int setVal) {  //mutator method to set the car count value

carCount = setVal;  } //set carCount so setVal

int GetCarCount() const {  //accessor method to get carCount

return carCount;  }  

private:  //private data member of class

int carCount;  };    // private data field of CarCounter

CarCounter::CarCounter() {  //constructor

carCount = 0;  //intializes the value of carCount in constructor

return; }  

// FIXME write copy assignment operator  

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

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

carCount = objToCopy.carCount;

return *this;}  

int main() {  //start of main() function

CarCounter frontParkingLot;  // creates CarCounter object

CarCounter backParkingLot;   // creates CarCounter object

frontParkingLot.SetCarCount(12);  // calls SetCarCount method using object frontParkingLot to set the value of carCount to 12

backParkingLot = frontParkingLot;  //assigns value of frontParkingLot to backParkingLot

cout << "Cars counted: " << backParkingLot.GetCarCount();  //calls accessor GetCarCount method to get the value of carCount and display it in output

return 0;  }

The output of this program is:

Cars counted = 12

You might be interested in
Identify the flaws / limitations in the following ConvertToNumber method:
lions [1.4K]

Answer:

Flaws and limitations identified in this program includes;

1.There was a not necessary usage of variable retrieval. Would have made use of canConvert.

2. Looking at the program, one will notice numerous typos. One of which is the fact that in JAVA we make use of Boolean instead of bool.

3.We rather use Integer.parseInt in JAVA and not Int16, cant make use of Int16.

4. The exception cant be printed

5. JAVA makes use of checkConversion instead of convertNumber as used in the program.

6. It cant work for decimal numbers, 0 and big integers.

Explanation:

See Answer for the detailed explaination of the flaws and limitations identified in the program.

4 0
3 years ago
From a neural network with 11 input variables, one hidden layer with three hidden units, and one output variable, how many param
e-lub [12.9K]

Answer:

40

Explanation:

Given that:

A neural network with 11 input variables possess;

one hidden layer with three hidden units; &

one output variable

For every input, a variable must go to every node.

Thus, we can calculate the weights of weight with respect to connections to input and hidden layer by using the formula:

= ( inputs + bias) × numbers of nodes

= (11 + 1 ) × 3

= 12 × 3

= 36 weights

Also, For one hidden layer (with 3 nodes) and one output

The entry result for every hidden node will go directly to the output

These results will have weights associated with them before computed in the output node.

Thus; using the formula

= (numbers of nodes + bais) output, we get;

= ( 3+ 1 ) × 1

= 4 weights

weights with respect to input and hidden layer total = 36

weights with respect to hidden and output layer total = 4

Finally, the sum of both weights is = 36 + 4

= 40

6 0
2 years ago
An excel worksheet can have a maximum of ____ columns in a worksheet.
Marina CMI [18]

It can have only 16,384 number of columns

6 0
3 years ago
A typeface, plus any special attributes applied to the text is called ________.
grandymaker [24]

Answer:

I would like to say font but not sure

3 0
2 years ago
Read 2 more answers
Mary has cleaned her data and is ready to determine the most efficient bus route. She starts by splitting the city into four reg
igomit [66]

ANSWER:

B.

Transforming the data might help Mary notice a different pattern that makes a bigger impact on bus routes than regions of the City.

EXPLANATION:

Mary can check if there are other things or factors that might influence where the bus routes need to be prioritized. For example if the students' age is considered for the bus routes instead of regions. She can achieve this by

By Re-sorting or Transforming the data.

That is to say she will be able to find out if it is only region or if there are different patterns that makes bigger impacts on bus routes, by transforming the data.

8 0
3 years ago
Other questions:
  • Money left over after the bills are paid is referred to as
    10·2 answers
  • Studying MyMagic+ helps one understand the costs associated with information systems deployment at scale. According to your read
    12·1 answer
  • A(n) __________ is a popular way to describe relationships? (i.e., one-to-one,? one-to-many) in a relational database.
    14·1 answer
  • When subjects are given two drinks but not told what they are drinking in order to get accurate results on which is the better t
    6·1 answer
  • How are natural systems and engineered systems similar to one another?
    8·1 answer
  • You load an image file into a numpy array and look at its shape, which is (433, 650). What does this indicate?
    13·1 answer
  • Which of the following statements is true of a server? Question 18 options: A) It supports processing requests from remote compu
    11·1 answer
  • How tp access to all tools in ms word
    10·1 answer
  • An organization using Robotic Process Automation (RPA) wishes to verify the quality and results of their automated processes to
    6·1 answer
  • Edhesive assignment 1 movie ratings
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!