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

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -