When should I use temporary variables?

Posted by Kyle on Stack Overflow See other posts from Stack Overflow or by Kyle
Published on 2010-04-27T21:30:02Z Indexed on 2010/04/27 21:33 UTC
Read the original article Hit count: 294

Filed under:
|
|
|
|

Specifically, I'm wondering which of these I should write:

    shared_ptr<GuiContextMenu> subMenu = items[j].subMenu.lock();
    if (subMenu)
        subMenu->setVisible(false);

or:

    if (items[j].subMenu.lock()
        items[j].subMenu.lock()->setVisible(false);

I am not required to follow any style guidelines. After optimization, I don't think either choice makes a difference in performance. What is generally the preferred style and why?

© Stack Overflow or respective owner

Related posts about c++

Related posts about styles