Previous Exercise to help with answering the question which is below | Write the header file (.h file) of a class Counter containing: A data member counter of type int. A data member named counterID of type int. A static int data member named nCounters. A constructor that takes an int argument. A function called increment that accepts no parameters and returns no value. A function called decrement that accepts no parameters and returns no value. A function called getValue that accepts no parameters and returns an int. A function named getCounterID that accepts no parameters and returns an int.   #include using namespace std; class Counter { private: int counter; int counterID; static int nCounters; public: Counter(int c); void increment(); void decrement(); int getValue(); int getCounterID(); }; ----------------------------------------------------------------------- ANSWER THIS QUESTION! In C++ Write the implementation (.cpp file) of the Counter class of the previous exercise. The full specification of the class is: A data member counter of type int. An data member named counterID of type int. A static int data member named nCounters which is initialized to 0. A constructor that takes an int argument and assigns its value to counter. It also adds one to the static variable nCounters and assigns the (new) value of nCounters to counterID. A function called increment that accepts no parameters and returns no value. increment adds one to the instance variable counter. A function called decrement that accepts no parameters and returns no value. decrement subtracts one from the counter. A function called getValue that accepts no parameters and returns an int. It returns the value of the instance variable counter. A function named getCounterID that accepts no parameters and returns an int. getCounterID returns the value of the data member counterID.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter11: Introduction To Classes
Section11.2: Basic Class Functions
Problem 5E
icon
Related questions
Question

Previous Exercise to help with answering the question which is below |
Write the header file (.h file) of a class Counter containing:

  • A data member counter of type int.
  • A data member named counterID of type int.
  • A static int data member named nCounters.
  • A constructor that takes an int argument.
  • A function called increment that accepts no parameters and returns no value.
  • A function called decrement that accepts no parameters and returns no value.
  • A function called getValue that accepts no parameters and returns an int.
  • A function named getCounterID that accepts no parameters and returns an int.

 

#include<iostream>
using namespace std;

class Counter
{
private:
int counter;
int counterID;
static int nCounters;
public:
Counter(int c);
void increment();
void decrement();
int getValue();
int getCounterID();
};



-----------------------------------------------------------------------

ANSWER THIS QUESTION!

In C++

Write the implementation (.cpp file) of the Counter class of the previous exercise.
The full specification of the class is:

    • A data member counter of type int.
    • An data member named counterID of type int.
    • A static int data member named nCounters which is initialized to 0.
    • A constructor that takes an int argument and assigns its value to counter. It also adds one to the static variable nCounters and assigns the (new) value of nCounters to counterID.
    • A function called increment that accepts no parameters and returns no value. increment adds one to the instance variable counter.
    • A function called decrement that accepts no parameters and returns no value. decrement subtracts one from the counter.
    • A function called getValue that accepts no parameters and returns an int. It returns the value of the instance variable counter.
    • A function named getCounterID that accepts no parameters and returns an int. getCounterID returns the value of the data member counterID.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Programming Logic & Design Comprehensive
Programming Logic & Design Comprehensive
Computer Science
ISBN:
9781337669405
Author:
FARRELL
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,