operator[]
takes size_t
i.e. an index but you're passing an iterator to it. If you want to do it with iterators then change the 4th line to this
if (*i >= *(i+1)) {
To avoid such confusion, an iterator is usually named iter
instead of the usual identifier used for a loop index or subscript, i
.
If you really want to do this without iterators but with index, then you could change the function to
int CardDeck::inOrder() {
for (size_t i = 1u; i < nameofdeque.size(); ++i) {
if (nameofdeque[i - 1] >= nameofdeque[i]) { // you cannot do this for the first element, hence the loop's variable starts at 1 to offset this
return 0;
}
}
return 1;
}