Hi there,

i need to know how to access my elements in a set of integers.

i have private data for the following:

private:
vector <bool> setlist; // indicates set elements as true
int cardinality; // number of items in set

im creating a function that 'dumps' the elements of the set out to the screen, but atm im only dumping out binary numbers.
understandbly since the its a bool type.
given that this is the private data how can i access the elements instead of the actual bool values.

i currently have a code as such :
for (int i =0; i < setlist.size(); i++){
cout << setlist.at(i) ;
}

regards

Recommended Answers

All 3 Replies

Why don't you use a vector of integers instead of booleans?
Add the integer values to the vector, and then print them out.
If I am misunderstanding the question please let me know.

yeh, that would be the quick way to rectify it but, its in " .h" file and i cannot amend it.

nobody has any idea?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.