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]
4 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]4 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]4 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
Briefly describe the fundamental differences between project-based and product-based Software Engineering.
andrew11 [14]

Answer:

Product-based companies make a specific product and try to market it as a solution. But project-based companies create a solution based on many products and sell it as a packaged solution to a particular need or problem.

Explanation:

hope this helps

8 0
3 years ago
1, and
zhannawk [14.2K]

Answer:

i think (first name last name id Num)

3 0
3 years ago
Unanswered questionl
antoniya [11.8K]

¿ ? ¿ ? Whattttt ? ¿ ? ¿

3 0
3 years ago
Which term best describes a network connection that uses the Internet to give mobile users or branch offices secure access to a
NNADVOKAT [17]

Answer:

Virtual Private Network (VPN)

Explanation:

A VPN can extend a private network over the internet securely to a mobile user or branch office. The traffic is encrypted between the private network and branch office or mobile users. VPN enables users to access and share resources like they were directly connected to the main network.

6 0
3 years ago
Which of the following items is an example of a user application? *
aleksandr82 [10.1K]

Answer:

I would probably say all of the above!

Explanation:

4 0
3 years ago
Read 2 more answers
Other questions:
  • Exercise 3: Function Write a function named word_count that accepts a string as its parameter and returns the number of words in
    10·1 answer
  • CAPTCHAs can be used as a form of signature to create a valid contract in e-commerce. True False
    6·2 answers
  • What would be the results of the following code? final int SIZE = 25; int[] array1 = new int[SIZE]; … // Code that will put valu
    9·1 answer
  • URLs are directions that browsers follow in order to find specific web page files. What is the first part of the URL that is the
    14·1 answer
  • Shelly tells a friend that her computer needs to be fixed because it has been producing a lot of heat and is smoking. Where is t
    10·1 answer
  • ____ is (are) the abuse of e-mail systems to send unsolicited e-mail to large numbers of people.
    14·1 answer
  • Which of the following statements best represents the impact vaudeville had on the film industry? Early silent films were more r
    14·1 answer
  • 2.11 (Separating the Digits in an Integer) Write a script that inputs a five-digit integer from the user. Separate the number in
    12·1 answer
  • List how much hard disk capacity you recommend, and write a sentence explaining why.
    8·1 answer
  • What are LinkedIn automation tools used for?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!