>Is the only solution, having a setCount and getCount for each private member?
Only if you need to set and retrieve each value individually, this is the most clear method but it gets combersome with larger classes. The trick is to minimize the number of private members that external sources need to view. Or you can be creative in how the data is accessed so as to minimize the number of class methods:
Code:
class counting
{
int countA;
int countB;
int countC;
public:
void setAll ( int x, int y, int z );
int getCount ( char mode );
};
void counting :: setAll ( int x, int y, int z )
{
countA = x, countB = y, countC = z;
}
int counting :: getCount ( char mode )
{
switch ( toupper ( mode ) ) {
case 'A': return countA;
case 'B': return countB;
case 'C': return countC;
default : return FAIL;
}
}
-Prelude