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
seraphim [82]
4 years ago
6

My programming lab 9.2 C++ Write a full class definition for a class named Counter, and containing the following members:_______

.
A) A data member counter of type int.
B) A constructor that takes one int argument and assigns its value to counter
C) A function called increment that accepts no parameters and returns no value.
D) Increment adds one to the counter data member.
E) A function called decrement that accepts no parameters and returns no value.
F) Decrement subtracts one from the counter data member.
G) A function called getValue that accepts no parameters.
H) It returns the value of the instance variable counter.
Computers and Technology
1 answer:
cupoosta [38]4 years ago
8 0

Answer:

class Counter {    

 public:

   int counter;

   Counter(int counter) {     // Constructor

     counter = counter;

   }

   void increment(){

      counter++;

  }

 

   void decrement(){

      counter--;

   }

    int getValue(){

       return counter;

   }

};

<h2><u>Explanation:</u></h2>

// Class header definition for Counter class

class Counter {    

// Write access modifiers for the properties(data members) and methods

 public:

  //a. Create data member counter of type int

   int counter;

   //b. Create a constructor that takes one int argument and assigns

   // its value to counter.

   Counter(int counter) {     // Constructor  with argument counter

    counter = counter;         // Assign the argument counter to the data

                                              // member counter

   }

   // c. Create a function increment that accepts no parameters

   // and returns no value (i.e void)

   void increment(){

      counter++;   // d. increment adds one to the counter data member

  }

 

   // e. Create a function decrement that accepts no parameters

   // and returns no value (i.e void)

   void decrement(){

      counter--;   // f. decrement subtracts one from the counter data member

   }

   // g. Create a function called getValue that accepts no parameters.

   // The return type is int, since the data member to be returned is of

   // type int.

    int getValue(){

       return counter; // h. it returns the value of the instance var counter

   }

}; // End of class declaration

Hope this helps!

You might be interested in
Visual Basic: What are arrays, please give an example code.
Drupady [299]

Answer:

An array is a collection of similar types of data. For example, if we want to store the names of 100 people then we can create an array of the string type that can store 100 names. String[] array = new String[100];

<h2>HOPE ITS HELPS YOU</h2>

4 0
2 years ago
Read 2 more answers
This isn't an academic question, but it's a question about something I am consistently seeing on Brainly, so please don't delete
s344n2d4d5 [400]
Yes it does. Hope that answers
3 0
2 years ago
Read 2 more answers
What is the type of data in the list [103, 405, 527, 396, 503]?
Mariulka [41]

Answer:

alphanumeric.........

3 0
3 years ago
Read 2 more answers
in which situation, a unicast session or a multicast session, can feedback received from an rtcp packet about the session be han
nikklg [1K]

The Real-time Transport Protocol is a network protocol that enables the Voice Over Internet Protocol by delivering streaming audio and video content over the internet (VoIP).

The datagram-oriented protocol is UDP. It is thus because none of the overhead associated with creating, maintaining, and closing connections exists. A network's ability to send audio and video depends on the RTP internet protocol. Designed for reliable live data delivery, the Real-time Transport Protocol (RTP) is a network standard for sending audio or video data. It is utilized in voice over IP, video telephony, and internet telephony. In the OSI model, RTP belongs to both the Presentation Layer (Layer 6) and the Session Layer (Layer 5).

Learn more about protocol here-

brainly.com/question/27581708

#SPJ4

3 0
1 year ago
Why can't mechanical switches be used in microprocessors
iren2701 [21]

Answer:

Microprocessor sometimes called the central processing unit.

Explanation:

Microprocessor is the heart of the computer network. It is useful in large agencies such as business, government, and our lives. This little chip is called the life of the computer. It is also called all computers life as we all know that. It is formed as the purest form of Moore law. It also said that this little chip also reached to its physical form.

The microprocessor sometimes called central processing unit or CPU. Mechanical switches are not used in microprocessor because of their easily interference. It has common problem called contact bounce.

4 0
3 years ago
Other questions:
  • Which of the following information security technology is used for avoiding browser-based hacking?
    11·2 answers
  • Which of the following devices is used to connect a computer to a network
    7·1 answer
  • How many electrons are there in an atom of carbon? A. Four B. Eight C. Six D. One
    15·2 answers
  • The picture that graphically represents the items you use in Windows is called a/an
    11·1 answer
  • How do I learn coding? Python
    5·2 answers
  • Durante 10s, la velocidad de rotación y el momento de giro de las ruedas de un coche eléctrico son 100 rpm y 1405,92 Nm, respect
    13·1 answer
  • Ranboo back story? (not homework i just wanna find some ppl who are interested in the same things) ft. the reddie meme
    9·2 answers
  • Which interpersonal skill is the most important for a telecom technician to develop?
    7·1 answer
  • When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This adjustm
    13·1 answer
  • A _______________ is a particular type of network that uses circuits that run over the Internet but that appears to the user to
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!