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
Evgesh-ka [11]
3 years ago
7

Write a full class definition for a class named Counter, and containing the following members: A data member counter of type int

. A data member named limit of type int. A static int data member named nCounters which is initialized to 0. A constructor that takes two int arguments and assigns the first one to counter and the second one to limit. It also adds one to the static variable nCounters A member function called increment that accepts no parameters and returns no value. If the data member counter is less than limit, increment just adds one to the instance variable counter. A member function called decrement that accepts no parameters and returns no value. If counter is greater than zero, decrement subtracts one from the counter. A member function called getValue that accepts no parameters. It returns the value of the instance variable counter. A static function named getNCounters that accepts no parameters and returns an int. getNCounters returns the value of the static variable nCounters.
Computers and Technology
1 answer:
vfiekz [6]3 years ago
4 0

// making the class

class Counter {

int counter;

int limit;

// Constructor

Counter(int a, int b){

counter = a;

limit = b;

}

// static function to increment

static increment(){

if(counter<limit)

nCounter+=1;

}

// Decrement function

void decrement(){

if(counter>0)

nCounter-=1;

}

int getValue(){

return counter;

}

static int nCounter;

int getNCounters(){

return nCounter;

}

};

// Initializa the static

int Counter::nCounter = 0;

You might be interested in
What are comments meant to do?
docker41 [41]
Comment<span> (computer programming) ... In computer programming, a </span>comment<span> is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters.</span>
8 0
3 years ago
All of the following can cause a fatal execution-time error except: Group of answer choices Dereferencing a pointer that has not
7nadin3 [17]

Answer: Dereferencing a variable that is not a pointer

Explanation:

The execution time also refered to as the CPU time pertaining to a given task is the time that is used by the system to execute a task.

Some of the reasons for a fatal execution-time error include:

• Dereferencing a pointer that has not been initialized properly

• Dereferencing a null pointer

• Dereferencing a pointer that has not been assigned to point to a specific address.

It should be noted that dereferencing a variable that is not a pointer doesn't cause a fatal execution-time error.

6 0
2 years ago
Please answer as soon as possible
kondaur [170]

its the first one x 3/14 bc 2/7 times 3/4 makes 6/28. 6/28 simplified is 3/14

8 0
3 years ago
How many bits are necessary for a binary representation (unsigned) of
Musya8 [376]
A. 5
b. as an unsigned int: 9. Normally a year is 365.25 days which would require 32-bits for an IEEE float.
c. 25
3 0
3 years ago
What is JavaScript? JavaScript is a _____ language.
disa [49]

Answer: dynamic computer language

Explanation:

JavaScript is a dynamic computer language. Hope this helps! (•‿•)

5 0
2 years ago
Read 2 more answers
Other questions:
  • Carson's supervisor has asked him to review a variety of portable computers for possible purchase for their company's employees.
    13·1 answer
  • What was the original intention for the creation of ARPANET?
    15·2 answers
  • Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished
    14·2 answers
  • 1. Implement a method factorial(int n), that takes a number (int) and returns its factorial. Factorial of an integer is the prod
    13·1 answer
  • As a digital strategist, Jared wants to add something extra to his ads to give users more incentive to click and convert. He's c
    11·1 answer
  • Creating a newsletter
    8·1 answer
  • Which of the following describes colors, spacing, borders, and other effects that change the appearance of a table?
    5·1 answer
  • "What is the capital of Belarus?" is an example of what type of search query
    10·2 answers
  • What are the 5 characteristics of flowchart<br>​
    14·1 answer
  • Project light with a system of lenses used for projecting slides or film into a screen.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!