Using a Vector of Booleans : vector definition « vector « C++ Tutorial






#include <vector>
#include <iostream>

using namespace std;

int main( )
{
   vector<bool> shots( 5 ); // true if pet has shot

   // give shots to two pets
   shots[1] = true;
   shots[4].flip();


   // delete the first element because that pet was adopted
   shots.erase( shots.begin() );


   // flip bits to show pets needing shots
   shots.flip();

}








16.11.vector definition
16.11.1.Using a Vector of Booleans
16.11.2.vector declaration
16.11.3.vector of 10 strings
16.11.4.Dynamically allocated vector begins with 0 elements
16.11.5.vector's copy constructor