Hey guys.
This is really frustrating because it seems easy but I can't seem to find the correct function to remove this element of my string.
void set::display() const
// pre : none
// post : displays the elements of this set enclosed in braces and
// separated by commas eg {1,2,3} or {} (do not use backspace, delete etc)
{
string s1 = ",";
cout << "{";
for (int i = 0; i < setlist.size(); i++)
{
if (setlist.at(i) == true)
{
cout << i;
cout << s1;
}
}
cout << "}";
}
At the moment it will output something similar to this:
{1,2,3,} --> notice the , after the last digit?
It needs to be this:
{1,2,3} --> no ',' after the last digit.
Any help would be appreciated,
Regards.
:)