Answer:
The following are the code in the C++ Programming Language.
//define header file
#include <iostream>
// using namespace
using namespace std;
//define a class
class Accumulator
{
//set private access modifier
private:
//declare integer type variable
int sum;
//set public access modifier
public:
//define constructor
Accumulator (int sum)
{
//refer the same class as instance variable
this->sum = sum;
}
//define integer type function
int getSum()
{
//return the value of sum
return sum;
}
//define void type function
void add (int value)
{
//variable sum is increased by the argument value
sum += value;
}
};
Explanation:
The following are the description of the code.