See operator Precedence, .
has higher precedence than *
*(agentlist.begin()).print();
represents as:
*((agentlist.begin()).print());
While iterator has no .print()
function call, compiler will throw out compile error.
You need:
agentlist.begin()->print(); or (*agentlist.begin()).print();