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
Write an algorithm to sum to values
Elis [28]

Answer:

There is no need to make an algorithm for this simple problem. Just add the two numbers by storing in two different variables as follows:

Let a,b be two numbers.

c=a+b;

print(c);

But, if you want to find the sum of more numbers, you can use any loop like for, while or do-while as follows:

Let a be the variable where the input numbers are stored.

while(f==1)

{

printf(“Enter number”);

scanf(“Take number into the variable a”);

sum=sum+a;

printf(“Do you want to enter more numbers? 1 for yes, 0 for no”);

scanf(“Take the input into the variable f”);

}

print(Sum)

Explanation:

hi there answer is given mar me as brainliest

5 0
3 years ago
Please help me, I honestly dont know what happened to my laptop.
Alex787 [66]
Restart the whole computer??
7 0
3 years ago
Read 2 more answers
Many subject elements make for simple and streamlined looking images. true or false
sukhopar [10]

Answer:

Explanation:

false. many elements means a complicated picture, not a simple one.

8 0
2 years ago
Which of the following are downlink transport channels?
Hunter-Best [27]
I think it’s a or b
4 0
2 years ago
If the value of score1 is 350 and the value of score2 is 210, what will be the value of result after the code segment is execute
MAVERICK [17]

  The value of result of the  code segment is executed is known to be 4.

<h3>Why is the value of the code segment so?</h3>

  When the result of  is not  executed because the condition is said to be false and also when there is a false condition is, the else statement will be said to be true

  Therefore,   result = result + 2; -> result is brought up by 2 to bring about 4 and as such, the value of result of the  code segment is executed is known to be 4.

Learn more about scores from

brainly.com/question/19492935

#SJ1

4 0
2 years ago
Other questions:
  • A factory has a dedicated room just for computers. They are generally kept locked in the room and are never directly used by use
    5·2 answers
  • Software (often on firmware) designed to make physical products and devices "smarter" by doing things like sharing usage informa
    12·1 answer
  • A(n) ________ converts your voice's sound waves into digital signals.
    9·1 answer
  • 1. A device that can be used to insert data into a computer or other computational devices is
    6·2 answers
  • Microcomputers, different from those giant mainframes and supercomputers, are designed for individuals. In fact, the microcomput
    7·1 answer
  • I have lost the watch (that,which) you gave me​
    12·1 answer
  • It's fill the gap homework
    7·1 answer
  • Political parties to address the interest of civil society<br>​
    7·1 answer
  • What are two potential benefits of using calendar-synchronization tools like calendly
    8·1 answer
  • in ____ structures, the computer repeats particular statements a certain number of times depending on some condition(s).
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!