Classes

Hi, my assignment is asking me to include accessor functions that returns the values stored in each of an object of class Voter’s member variables respectively.

If the member variables are:
string ID;
int nr_times_voted;
bool voted;

Will the accessor functions be:

Voter::getID()
{
return ID;
}

Voter::getNr_times_voted()
{
return nr_times_voted;
}

Voter::getVoted()
{
return Voted;
}

Not sure I understand this exactly.
You'll need return types, just like in regular functions. The exception is that dtors/ctors do not return anything.

Also, try using code tages (the little button that says <>).
Topic archived. No new replies allowed.