c++ - Syntax for extracting pointer from container back() -
is acceptable syntax? looks messy tends make me think not elegant:
cdata.lastanimation=&(this->animations.back());
cdata.lastanimation pointer, since back() returns reference, not pointer, need address?
you might thinking, why not make cdata.lastanimation reference instead of pointer? because cdata pod struct , references cannot assigned, unlike pointers, can. (perhaps 1 of few examples of why pointer better in cases reference).
yes, work fine, though can (very seldom not) shortened this:
cdata.lastanimation = &animations.back(); that seems little bit better me @ least.
Comments
Post a Comment