Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Problem programmer?

Name: Anonymous 2011-04-20 14:49

in main:

vector<int> player_nr;
int x = menu(player_nr.begin());

menu function:

int menu(vector<int>::iterator x)
{
...
int a = x->size(); //<---- complains here
...
}

As far as I understood it Vectors have the arrow-operator defined in C++. Then why the fuck does the compilator complain of it?

Name: Anonymous 2011-04-20 15:36

>>4
Have you tried reading the error mess... wait, it's C++.

First of all, when you want to access properties of the iterator itself, you use '.' (dot). '->' or, equivalently, '(*it).' accesses methods/fields of the object that the iterator currently points at.

Second, where did you get the funny idea that iterators can have size? They are only required to define ++, --, +=(size_t), -=(size_t), and dereference (prefix '*' and '->' that uses it).

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List