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
Blogs differ from most other online text sources because they
allochka39001 [22]
Tell you what a person's life is like
4 0
3 years ago
Read 2 more answers
On the basic of size, in how many groups do we classify the computers? Name them.<br>.​
Vedmedyk [2.9K]

Answer:

Computer can be classified into four categories based on size namely Micro, Mini, Mainframe and Super computer

Explanation:

8 0
3 years ago
Write a program in C++ to implement bubblesort using the swap function ?
marishachu [46]

C++ program for implementation of Bubble sort  

#include <bits/stdc++.h>  

using namespace std;  

 void swap(int *x, int *y)  /*Defining Swap function of void return type*/

{  

  int temp = *x;  //Swaping the values  

   *x = *y;  

   *y = temp;  

}  

void bubbleSort(int array[], int n) /*Defining function to implement bubbleSort  */

{  

  int i, j;  

  for (i = 0; i < n-1; i++)      

      for (j = 0; j < n-i-1; j++)  /*The last i components are already in location  */

      if (array[j] > array[j+1])  

          swap(&array[j], &array[j+1]);  //Calling swap function

}  

int main()  //driver function

{  

   int array[] = {3, 16, 7, 2, 56, 67, 8}; //Input array  

   int n = sizeof(array)/sizeof(array[0]);  //Finding size of array

   bubbleSort(array, n); //Function calling  

   cout<<"Sorted array: \n";  

   for (int i = 0; i < n; i++)  //printing the sorted array

       cout << array[i] << " ";  

   cout << endl;  

 return 0;  

}  

<u>Output</u>

Sorted array:  

2 3 7 8 16 56 67

3 0
3 years ago
You work as the IT administrator for a small business and are responsible for the corporate network. Until now, the network has
posledela

Answer:

Extend a Volume:

1. in the lower left-hand corner, R click the start page thumbnail and select disk management

2. if needed, click ok to initialize any new disks.

3. R click the volume and select extend volume.

4. click next.

5. for the system volume, you can only extend the volume onto the existing disk. type the amount of disk space to add to the volume and click next. click finish.

Convert a Disk to Dynamic

1. In Disk management, R click the disk and select convert to Dynamic Disk

2. Select the disk to convert, click ok.

3. Click convert

4. If the disk contains a volume, you will be shown a warning message. Click Yes to continue.

Create a Spanned Volume

1. In disk management, R click a disk or free space on a disk and select New Spanned Volume.

2. Click Next

3. Select the disks that will be part of the spanned volume and click Add. You must select at least 2 disks to create a spanned volume.

4. To modify the amount of space used on a disk for the new volume, select the disk in the right box, and then edit the number in the select the amount of space in MB: field.

5. Click next

6. Select the drive letter and click Next

7. Type the volume label, then click next

8. Click finish

9. If the new volume includes a space from a disk that is currently a basic disk, you will be prompted to convert the disk to a dynamic disk. Click Yes to create the volume.

Explanation:

5 0
2 years ago
has anyone noticed to get credit for answering a question you don't even need to answer it correctly?
Helga [31]

Yes I've noticed this. Unfortunately it's up to the user (Asker) to report an answer incorrect.

8 0
3 years ago
Read 2 more answers
Other questions:
  • Which of the following journals is not aimed at the public as well as scientists?
    7·1 answer
  • When might be the best time to start saving for retirement?
    5·2 answers
  • When evaluating portable CD players, you consider price, the sound quality, and ease of using the controls. These are your _____
    8·2 answers
  • This whole page needs to be done please help?
    13·1 answer
  • While the names for Web addresses, or URLs, are not case-sensitive, the names for files you create for the Web are. 
    11·1 answer
  • What is social media ​
    13·2 answers
  • Write the difference between left-sentential form and <br> right-sentential form
    13·1 answer
  • How many basic elements of QBASIC are there
    14·1 answer
  • Five types of conflict in the school​
    9·2 answers
  • 7. Type the correct answer in the box. Spell all words correctly.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!