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
What is data anayltics
Lena [83]
Data analytics<span> (DA) is the science of examining raw </span>data<span> with the purpose of drawing conclusions about that information. </span>Data analytics<span> is used in many industries to allow companies and organization to make better business decisions and in the sciences to verify or disprove existing models or theories.</span>
7 0
3 years ago
What science category includes physics and biology?
enyata [817]

Answer:

Physical science is the study of the inorganic world. That is, it does not study living things. (Those are studied in biological, or life, science.) The four main branches of physical science are astronomy, physics, chemistry, and the Earth sciences, which include meteorology and geology.

5 0
2 years ago
Suppose that a 64MB system memory is built from 64 1MB RAM chips. How many address lines are needed to select one of the memory
alexdok [17]

Answer:

6 address lines

Explanation:

The computation of the number of address lines needed is shown below:

Given that

Total memory = 64MB

= 2^6MB

=2^{26} bytes

Also we know that in 1MB RAM the number of chips is 6

So, the number of address lines is 2^{26} address i..e 26 address lines

And, the size of one chip is equivalent to 1 MB i.e. 2^{20} bytes

For a single 1MB chips of RAM, the number of address lines is

\frac{2^{26}}{2^{20}} \\\\= 2^6 address

Therefore 6 address lines needed

5 0
3 years ago
Choose the appropriate software category for each specific application shown.
Tom [10]
Python is the correct answer
7 0
2 years ago
The set of rules for how computers talk to one another
andrezito [222]
That is program ............
4 0
3 years ago
Other questions:
  • design aDesign a queue abstract data type for float elements in a language that you know, including operations for enqueue, dequ
    10·1 answer
  • 1. Which of the following is not related to a buffer overflow? A. Static buffer overflow B. Index error C. Canonicalization erro
    10·1 answer
  • What is the multiple source test
    15·1 answer
  • Assume that sentence is a variable that has been associated with a string consisting of words separated by single space characte
    12·2 answers
  • You Could Never Size Me UP! Been Doing This Sh*t A Long ⏱time
    15·1 answer
  • Braxton is writing a program to design t-shirts. Which of the following correctly sets an attribute for color?
    7·1 answer
  • Question #5
    14·1 answer
  • I'm getting pretty desperate plz help me, I'll give brainiest, and ill make a free question worth 100 points this is for coding
    8·2 answers
  • Frrrrrrrrrrreeeeeeeeee brainliest for u
    13·2 answers
  • An entity is said to be _____-dependent if it can exist in the database only when it is associated with another related entity o
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!