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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education