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]
4 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]4 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 is green computing in non-technical term?​
DochEvi [55]

Answer:

Green computing is also known as green information technology (green IT)

4 0
3 years ago
Figure out what this says:<br><br> ?driew tib a kool ti seoD
lisov135 [29]

Answer:

Does it look a bit weird?

5 0
3 years ago
Debugging is not testing, but always occurs as a consequence of testing. <br> A) TRUE<br> B) FALSE
kherson [118]
A) True Hope that helps
5 0
4 years ago
What are two fundamental components of data structures?
Fed [463]
Organization and access method.

Hope this helped! :)

- Jujufire
8 0
4 years ago
What was the first computer to defeat a world champion chess player?
deff fn [24]
deep blue IBM's chess-playing computer
6 0
4 years ago
Other questions:
  • In the CIA Triad, "Confidentiality" means ensuring that data is
    9·1 answer
  • Tom is required to present the activities of his Nature club each month to the school committee. Which presentation element can
    12·2 answers
  • Given a int variable named calls Received and another int variable named operators On Call write the necessary code to read valu
    14·1 answer
  • You want to use a wireless keyboard and mouse with your laptop computer. which method should you use
    11·1 answer
  • At one college, the tuition for a full-time student is $6,000 per semester. It has been announced that the tuition will increase
    12·1 answer
  • What is the primary advantage of a 64-bit operating system versus 32-bit
    8·1 answer
  • Universal Containers (UC) uses a custom object called Vendor. The Vendor custom object has a Master-Detail relationship with the
    10·1 answer
  • Give an original idea for an app idea to do with sports, please.
    9·1 answer
  • Complete the function to return the factorial of the parameter using recursion,
    10·2 answers
  • In 1839, Talbot released the paper-based process which he called _ to the public.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!