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]
3 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]3 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
A body performing Shm has a velacity of 12m/s when the displacement is 100mm the displacement
Assoli18 [71]

Answer:

vjcyfuy

Explanation:

yjvjy

4 0
3 years ago
What considerations should you make when deciding on the size of a table?
Kisachek [45]

Answer:

You should consider the number of cells needed for data, labels, titles, and formulas.

Explanation:

4 0
3 years ago
Which step creates a connection between a file and a program in python?
Mandarinka [93]
<span>The step of opening a file creates a connection between a file and a program.Opening an output file usually creates the file on the disk and allows the program to write data to it.Opening an input file allows the program to read data from the file.</span>
5 0
3 years ago
Felicia is a computer programmer.
dolphi86 [110]

A: SSD, HDD, CPU or RAM

Whether you go with the faster SSD or slower but larger HDD, keep in mind you may end up needing a drive large enough to run a dual boot system if you plan on coding in multiple environments. Virtualization of other operating systems is another option, but that requires a fast CPU and a large amount of RAM to work well.

B: Ram because its larger than the others, and will work better.

C: i don't really have a suggested system but here

You may appreciate the seamless experience iOS offers, the flexibility of Android or the familiarity of Windows with your everyday PC. It might take some time to acclimate to a new system, so it may be best to stick with what you know.

Please consider marking brainliest.. thx

8 0
3 years ago
What should a valid website have?
zzz [600]
The answer is A.....
4 0
3 years ago
Other questions:
  • What does CTR stand for?
    10·2 answers
  • Easy question how the internet has impacted y’all life
    13·1 answer
  • Ideally an entity identifier is composed of _____ attribute(s).
    11·1 answer
  • Write a python function c that converts bitstring array back to an integer numpy array
    5·1 answer
  • The number of bits that can be transferred per second over a given transmission medium.
    6·1 answer
  • During which phase of film making does the team outline their vision for the film?
    5·1 answer
  • Which statistical function in a spreadsheet helps you to see how far each number varies, on average, from the average value of t
    5·1 answer
  • Which of the following is important to consider before believing health or fitness information you find online?
    12·1 answer
  • Which types of scenarios would the NETWORKDAYS function help calculate? Check all that apply.
    15·1 answer
  • PLEASE ANSWER AND HURRY I'LL MARK YOU BRAINLIEST!!<br><br><br>​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!