Reputation: 273
What is this piece of code doing?
SNMP_Sequence trapseq = trap.GetPDU().GetVarBindList();
As far as I know, an object can refer to only one member function at a time.
What is happening here?
trap.GetPDU().GetVarBindList()
Upvotes: 0
Views: 71
Reputation: 206566
trap.GetPDU()
returns an object and GetVarBindList()
is called on that object.
trap.GetPDU().GetVarBindList()
is equivalent to:
obj.GetVarBindList()
where obj
is an object returned by trap.GetPDU()
This is also known as Method Chaining.
Upvotes: 4
Reputation: 146968
It is perfectly legitimate to call a member function upon the result of any expression, including the access to another member, should that expression be of appropriate type.
std::vector<std::vector<std::vector<std::string>>> super_jaggy;
// insert stuff here
std::cout << super_jaggy.front().front().front().size(); // legal
Upvotes: 0
Reputation: 16718
It's retrieving the object (or reference) that GetPDU
returns, and then calling GetVarBindList
on it.
Equivalent to something like:
SomeObject &PDU = trap.GetPDU();
SNMP_Sequence trapseq = PDU.GetVarBindList();
Upvotes: 0