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
A user saves a password on a website the user logs into from a desktop. Under which circumstances will the password be saved on
artcher [175]

Answer:

same encryption certificate

Explanation:

only logical xD

4 0
3 years ago
Effective nonverbal communication can cause tension.<br><br> True or False
agasfer [191]

Explanation:

When your nonverbal signals match up with the words you're saying, they increase trust, clarity, and rapport. When they don't, they can generate tension, mistrust, and confusion.

4 0
3 years ago
The program that solves problem 2 (a) on p.275 should be named as proj4_a.c. It must include and implement the following functio
avanturin [10]

Answer:

#include <iostream>

#include <cstring>

using namespace std;

bool isAPalindrome(char* palindrome);

int main()

{

   char palindrome[30];

   bool palindrome_check;

   cout << "Please enter an word or phrase.\n";

   cin.getline(palindrome, 30);

   palindrome_check = isAPalindrome(palindrome);

   if (palindrome_check = true)

   {

       cout << "Input is a palindrome\n";

   }

   else

   {

       cout << "Inputis not a palindrome\n;";

   }

system("pause");

return 0;

}

bool isAPalindrome(char* palindrome)

{

   char* front;  

   char* rear;  

front = palindrome;// starts at the left side of the c string

rear = (palindrome + strlen(palindrome)) - 1;//starts at the right side of the c-string. adds the c string plus the incriment value of s

while (front <= rear)

{

 if (front = rear)

 {

  front++;

  rear--;

 }

 else

 {

  return false;

 }

}

   return true;

}

7 0
2 years ago
During an engine's intake stage, what passages inside the cylinder head of a gasoline powered engine must the incoming air-and-f
kow [346]
The intake ports must be open to allow fuel and oxygen to enter cylinder, then closes during compression. Your answer is A.
3 0
3 years ago
____________ provides the architect opportunity to electronically plan and place elements of a building.
Snowcat [4.5K]
CAD provides the architect opportunity to electronically plan and place elements of a building. The correct option among all the options that are given in the question is option "c". The full form of CAD is Computer Aided Design. It gives the designers the opportunity to create three dimensional pictures.
5 0
3 years ago
Read 2 more answers
Other questions:
  • What do students buy when they pay tuition?
    6·2 answers
  • What is a computer ?it types​
    11·2 answers
  • (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle t
    6·1 answer
  • Anybody good with Microsoft excel? I need help with this class.
    9·2 answers
  • Which of the following is no longer necessary when you use HTML5 to develop Webpages? Please Hurry This Is For An Assignment due
    13·1 answer
  • A key physical design element is the ____, which describes how users interact with a computer system
    11·1 answer
  • What other options are there besides jail for 16 year old that commit a crime?
    8·2 answers
  • I wrote a program to calculate how many unique students I have taught over the years. It will read in a file formatted with firs
    5·1 answer
  • Which programming paradigm does the programming language JavaScript follow?
    14·1 answer
  • 1. what is the purpose of giving an id to an html element when using javascript?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!