Hey guys.
I need help on how to set a specific element that I insert into my vector of bool type :S
set::set()
{
cardinality = 0;
setlist.resize(DEFAULTSIZE, false);
}
void set::insert(int x)
{
if (x >= 0 && x <= DEFAULTSIZE)
{
setlist.insert(setlist.begin(), 1, x);
x = true;
cardinality++;
}
}
void set::dump() const
{
for (int i = 0; i < DEFAULTSIZE; i++)
{
if (setlist.at(i) == true)
{
cout << i << " ";
}
}
}
Okay, so when I create the set, all elements of DEFAULTSIZE ie. 100 elements are all set as false by default.
But I want my insert(int x) function to insert a value x, but set it to true so that my dump() function can only display the values set as "true" in the set created.
Any help would be appreciated, because I tried doing x = true after the setlist.insert function but it still does not set x as true.
Thanks :)