Bit of a nooby question here but I was wondering what the parentheses around the pointer in the for loop mean/do. I understand that the * is dereferencing the iterator, but I've never had to put parentheses around a pointer when dereferencing it before.
Oh, my bad. That's done for clarity, so that you know the dereference operators should resolve in that order. First the iterator dereferences to a pointer of type "Drawable" then the -> operator selects the member function from the data that the pointer is pointing at. Otherwise you're looking for a member function that doesn't exist.
Technically speaking, itrbegin is an iterator and not a pointer.
The technical difference between pointers and iterators is that pointers are bult-in into the language (variables that hold a memory address) while iterators are usually coded as classes that overload operator* and operator->, among others (so they can be used as if they were pointers).
By the way, do not confuse the asterisk symbol (*) when used in declaring a pointer, with when it's an operator.
1 2 3 4 5 6
double *p; // * is not an operator, but part of the pointer declaration
double d;
p = &d;
*p = 10.0; // * is the dereference operator
d = 20.0 * 3.0; // * is the multiplication operator
Also, the parentheses are used because operator-> has precedence over operator*.
1 2 3
(*itrbegin)->printName(); // not the same as...
*itrbegin->printName(); // which would in fact be the same as...
*(itrbegin->printName());