No, it cannot. The definition of a local variable is that its life is determined by the scope of its declaration. But you can limit the scope if you want.
Qt Code:
Cat *tofi = new Cat(); { Cat smuki; delete tofi; //object on the heap deleted ok } // smuki undeclared past this pointTo copy to clipboard, switch view to plain text mode
Very good, thanks.No, it cannot. The definition of a local variable is that its life is determined by the scope of its declaration. But you can limit the scope if you want.
Qt Code:
Switch view
Cat *tofi = new Cat();
{
Cat smuki;
delete tofi; //object on the heap deleted ok
} // smuki undeclared past this point
Bookmarks