STD List Container

I came across something strange that I haven’t seen in C++ before. On line 35 I dereference a iterator like this:


Why do I have to use the brackets and why does *iterator not work?

I posted the code on for code colors:

That’s how you tell c++ what to do first.

And because iterators point to pointers It**?!

*(A)->Method(); tells the compiler to dereference A first then call Method();

More info here:

As Azarus said, it’s an order of operations issue.

The indirect access operator (->) has higher precedence than the dereference operator (*). Putting (*iterator) makes sure that the dereference happens first.

Okay I see. Thanks!