I have some code given to me by another person in which we have a structure
struct Pair {
string s1;
string s2;
bool equivalent;
};
Why is it failing?
Because it’s not valid C++. It will be, in C++0x. But as of yet, it’s just not valid. And since your compiler doesn’t yet support C++0x, you will need to do it the hard way, i.e. populate the vector one element at a time, or copy from a C array …:
Pair data[] ={ {"string","string2",true},
{"string","string3",true},
{"string","string4",false},
{"string","string7",false},
{"string3","string8",false} };
PairID.assign(data, data + sizeof(data) / sizeof(Pair));
(This will require the algorithm
and iterator
standard headers.)