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
maw [93]
3 years ago
15

Write a copy constructor for carcounter that assigns origcarcounter.carcount to the constructed object's carcount. sample output

for the given program:
Computers and Technology
2 answers:
Drupady [299]3 years ago
8 0

#include <iostream>

using namespace std;

class CarCounter {

  public:

     CarCounter();

     CarCounter(const CarCounter& origCarCounter);

     void SetCarCount(const int count) {

         carCount = count;

     }

     int GetCarCount() const {

         return carCount;

     }

  private:

     int carCount;

};

CarCounter::CarCounter() {

  carCount = 0;

  return;

}

CarCounter::CarCounter(const CarCounter &p){

carCount = p.carCount;

}

void CountPrinter(CarCounter carCntr) {

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

  return;

}

int main() {

  CarCounter parkingLot;

  parkingLot.SetCarCount(5);

  CountPrinter(parkingLot);

  return 0;

}

Sample output:  

Cars Counted: 5

katen-ka-za [31]3 years ago
7 0

Answer:

import java.util.Comparator;

import java.util.PriorityQueue;

 

public class PriorityQueueTest {

 

static class PQsort implements Comparator<Integer> {

 

 public int compare(Integer one, Integer two) {

 return two - one;

 }

}

 

public static void main(String[] args) {

 int[] ia = { 1, 10, 5, 3, 4, 7, 6, 9, 8 };

 PriorityQueue<Integer> pq1 = new PriorityQueue<Integer>();

 

 // use offer() method to add elements to the PriorityQueue pq1

 for (int x : ia) {

 pq1.offer(x);

 }

 

 System.out.println("pq1: " + pq1);

 

 PQsort pqs = new PQsort();

 PriorityQueue<Integer> pq2 = new PriorityQueue<Integer>(10, pqs);

 // In this particular case, we can simply use Collections.reverseOrder()

 // instead of self-defined comparator

 for (int x : ia) {

 pq2.offer(x);

 }

 

 System.out.println("pq2: " + pq2);

 

 // print size

 System.out.println("size: " + pq2.size());

 // return highest priority element in the queue without removing it

 System.out.println("peek: " + pq2.peek());

 // print size

 System.out.println("size: " + pq2.size());

 // return highest priority element and removes it from the queue

 System.out.println("poll: " + pq2.poll());

 // print size

 System.out.println("size: " + pq2.size());

 

 System.out.print("pq2: " + pq2);

 

}

}

You might be interested in
What is zenmap typically used for? how is it related to nmap? describe a scenario in which you would use this type of applicatio
slava [35]

Zenmap is the graphical User Interface representation for NMAP Security Scanner. It is an open-source program designed to make NMAP easy for starters to use. Typically, it is used to collect and identify a list of hosts, OS, as well what services are running on them by using a port scanning tool. It is used specifically for the scanning and vulnerability phase of ethical hacking.

A network administrator who wishes to audit all the devices on a specific IP scheme in a network can use NMAP. The admin can go ahead and scan the ports to know exactly which ports are closed and which are opened.






8 0
3 years ago
While your hands are on home row, your left hand rests lightly on _____.
In-s [12.5K]
The answer is b. asdfc.  
8 0
3 years ago
Read 2 more answers
True or False: At the Company level, users will only have access to view projects to which they have been specifically granted a
Viktor [21]

Answer:here the link

Explanation:

4 0
3 years ago
Read 2 more answers
All of the following are parts of the word processing window except _____. \
Rainbow [258]
<span>All of the following are parts of the word processing window except for the button esc ____.</span>
5 0
3 years ago
Members of the sales team use laptops to connect to the company network. While traveling, they connect their laptops to the inte
coldgirl [10]

Answer: Network access control (NAC)

Explanation:

The solution that should be used is the network access control. Network access control helps in keeping devices and users that are unauthorized out of ones private network.

In this case, since one will like to prevent the laptops from connecting to the network unless anti-virus software and the latest operating system patches are installed, then the network access control can be used. One can only give access to the device that it wants to give access to and prevent others from connecting.

3 0
2 years ago
Other questions:
  • Marisol manages the online advertising campaigns for a chain of toy stores with both a physical and an online presence. Which Go
    7·1 answer
  • Which options correctly describe Andrew's job role?
    6·1 answer
  • Which question best addresses the issue of risk with a new job?
    7·2 answers
  • [Submit on zyLabs] Please write a function with one input, a matrix, and one output, a matrix of the same size. The output matri
    10·1 answer
  • Follow up, my brother is upset at me for stealing his robux, what should i do?
    11·2 answers
  • Managing your calendar and emails can be easily accomplished through ___ software
    8·1 answer
  • in java how do i Write a program that reads a set of integers, and then prints the sum of the even and odd integers.
    6·1 answer
  • The number of pixels displayed on the screen is known as ________.
    13·1 answer
  • Any device that uses light to read and write information.
    9·2 answers
  • There is a surplus of scientific researchers for a vaccine. This means the demand for this career has
    8·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!