answer.
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]
2 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]2 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]2 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
"use the ______ element to create logical areas on a web page that are embedded within paragraphs or other block formatting elem
8090 [49]

Answer:

"use the span element to create logical areas on a web page that are embedded within paragraphs or other block formatting elements."

Explanation:

  • The question is associated with HTML and web pages. As span is a type of function in HTML.
  • <span> element is actually a generic in-line tool/container which is used for content phrasing. Its functionality is much like a <div> element but <div> is a block-level element and on the other hand <span> element is in-line element.

  • <span> element groups elements for styling purposes, but it does not represents anything inherently.

5 0
2 years ago
3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?
Charra [1.4K]

Answer:

3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?

Explanation:

3. Choosing a pre-formatted presentation (that already has a design in the slides) is called choosing a ?

7 0
2 years ago
Gloria needs to show in spreadsheet form the number of students in her class who speak different languages. Which type of graph
vaieri [72.5K]
I think the most suitable chart to be used is a pie chart. A pie chart is used to show percentages and the best way to show relative sizes of data in your set. It is a good way to show which language is spoken more in the classroom, which is least spoken and at a glance. I hope my answer helps.
4 0
2 years ago
Which statements describe the Sort List feature of Word? Check all that apply.
natulia [17]

Answer: It arranges text in a list alphabetically from A to Z.

Explanation: It's always easier and more systematic to arrange alphabetically. With numbers there is the possibility of infinity but not with alphabet which have a defined range.

7 0
2 years ago
Read 2 more answers
HackerCards is a trendy new card game. Each type of HackerCard has a distinct ID number greater than or equal to 1, and the cost
joja [24]

Answer:

I don't know if this is right output is {1,3}

Explanation:

5 0
2 years ago
Other questions:
  • Many organizations keep copyrighted information on their intranets, which is one reason usernames and passwords are required. Tr
    13·1 answer
  • In what year were graphical user interfaces (GUIs) pioneered? 1969 1974 1991 2001
    12·2 answers
  • In Python, what kind of error is returned by the following code? (e.g. NameError, ValueError, IOError, etc.) def my_func(n1, n2)
    8·1 answer
  • A network design engineer has been asked to design the IP addressing scheme for a customer network. The network will use IP addr
    6·1 answer
  • To reduce costs and the environmental impact of commuting, your company decides to close a number of offices and to provide supp
    11·1 answer
  • Database management systems are expected to handle binary relationships but not unary and ternary relationships.'
    7·1 answer
  • Write a function that computes the average and standard deviation of four scores. The standard deviation is defined to be the sq
    15·1 answer
  • You have configured your firewall to authenticate a group of 100 users who are in your company. You set up the database of users
    14·1 answer
  • The term Electronic Privacy Information Center (EPIC) refers to a form of the digital subscriber line technology, which enables
    6·1 answer
  • As a security engineer, compare and contrast the pros and cons of deploying hetero vs homogenous networks. Which costs more? Whi
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!