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 are attribute grammars used for?
umka21 [38]

Explanation:

Attribute Grammars were invented by Don Knuth as a way to unify all of the stages of compiling into one. An attribute grammar links syntax with semantics and have values that hold semantic information about the (non)terminal.  

<em>They can perform several functions in specifying the syntax and semantics of a programming language, they can specify the context-sensitive aspects of the syntax of a language and operational semantics of a programming language.</em>

I hope you find this information useful and interesting! Good luck!

4 0
3 years ago
________ is a dedicated device designed to manage encrypted connections established over an untrusted network such as the Intern
pantera1 [17]

Answer:

The correct answer to the following question will be Option B (VPN concentrator).

Explanation:

  • Virtual Private Network (VPN) is a virtual, limited-use network generated using protocol encryption and tunneling over physical, public network connections.
  • A dedicated tool for managing VPN connections built over an untrusted network, such as the Internet, is called a VPN concentrator.
  • It's a type of networking system that ensures secure VPN connections are established and messages are transmitted between VPN nodes.

Therefore, Option B is the right answer.

7 0
3 years ago
You type a web address in your web browser. order the steps, which describe the internet name resolution process for the web add
padilas [110]
First of all let's make it clearer, what is meant by "domain name resolution"?
"Domain name resolution" is the process of translating your web address into its corresponding IP address. e.g. translating (www.brainly.com to 104.16.32.180)
Computers cannot understand the human language they only can understand numbers that's why we need this process.

So, the process (in a very simple way) is divided into four steps:
1) Lookup "root nameservers"
2) Lookup "Top Level Domain TDL nameservers"
3) Lookup "domain nameservers"
4) Lookup "subdomain nameservers" [if exist]

If you still confused please check out this video https://www.youtube.com/watch?v=BCjUbpIzRs8&index=10&list=PL4bq-KmCeyBmMvBB3-RT6ikdp8ljV9GeT

6 0
3 years ago
Which type of chemical bonds are formed by sharing electrons?
Elza [17]
The type of chemical bond which forms by sharing electrons is ionic
6 0
3 years ago
Kenny FRIEND ME. Ps that is my brother
Maslowich

Answer:

who is kenny

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Abigail is interested in connecting her tablet that usually connects to a wireless network, to her personal computer that usuall
    11·2 answers
  • Lydia used software and numerical data to create bar graphs. What software did she use?
    8·2 answers
  • Identify the four basic categories of hardware in a microcomputer system. system unit, modem, ram, and microprocessor system uni
    5·1 answer
  • The Internet and World Wide Web allow almost any business to be global. What are two important results of this process?
    8·1 answer
  • A company has its branches spread over five places in a state. It has become difficult for employees to transfer information and
    7·1 answer
  • Which communication technology should you use if you need to connect three offices which are all within 3 miles of each other at
    6·1 answer
  • What is a Software that interprets commands drom the keyboard and mouse
    13·1 answer
  • What are the advantages of customer relationship managment​
    10·1 answer
  • Explain different types of networking-based attacks
    5·1 answer
  • Can somebody PLEASE help me cancel my subscription I have tried so many different things and contacted support - they are no hel
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!