On Nov 23, 10:02 pm, nosbor <arobso...@yahoo.co.uk> wrote:
> Hi
> i have defined
>
> typedef vector<string,bool> list_check;
>
> how do i add elements to list_check ?
>
> normally i would just use vector<type> , but am wondering if there is
> a way to add things to list_check type.
>
> would be nice to be able to do:
>
> list_check.push_back("some_string",true);
>
> but i get errors.
>
> list_check lc();
>
> compiles of , its when i try to add things to it i get more strange
> errors.
> help appreciated.
If you intend to map an index to a pair of a (string,bool) you could
do the following:
typedef pair<string, bool> pairCheck;
typedef vector<pairCheck> list_check; // Wouldn't vector_check be a
better name?
Add item using the following:
list_check.push_back(make_pair(string("some_string"),true));