More specifically the opening "*" within the Lookup method.
As I understand it: fleet->Owners() would be a references to a method of whatever fleet is pointing to. fleet->Owners().begin() would be a method of whatever object that method returns?
So *fleet->Owners().begin() would be a pointer to the object that the begin() method returns?!
In this context, * is the dereferencing operator. If used on a pointer, it would return whatever the pointer points to. If used on an iterator, it's been overloaded to return what the iterator points to.
So:
fleet->Owners() returns a std::set<int>
.begin() acts on the set and returns a std::set<int>::iterator that points to the first int in the set
* acts on the iterator, and returns the int that the iterator points to
Empires() returns an object that has a member function Lookup that takes a single int parameter.
Lookup is passed the int that is returned by the * operator and returns a pointer to an Empire object
->Color() is called on the returned Empire object, and returns a GG::Clr
* can also be used to declare a pointer, but that's not how it's being used here.
Note that you can get a pointer to (the address of) a variable using the & operator.
int x = 5; // declares and initializes int with value 5
int* int_pointer = &x; // declares a pointer to int and initializes with the address of the int x
int y = *int_pointer; // declares another int and initializes with the value of the int pointed to by int_pointer
Replaced "int" with another type or class and things should work the same.
Great! Thanks for clarifying. I think I had the concept, but I haven't had to worry about pointers in a long while. I've been doing C# programming in .NET at my day job, so that's a bit of a different animal. Thanks again!