30.3k views
4 votes
write the header file (.h file) of a class acc2 containing: a data member named sum of type int. a constructor accepting no parameters. a function named getsum that accepts no parameters and returns an int.

1 Answer

5 votes
// acc2.h

// c++ class header for acc2
class acc2
{
public:

// getsum()
int getsum()
{
return sum_;
}

// Default constructor
acc2()
{
sum_ = 0;
}

private:
int sum_;
}
User SuperM
by
3.6k points