I found in samples code where to Construct() method of object is passed temporary object:
Label* pLabel3 = new Label(); pLabel3->Construct(Rectangle(0,0,150,80), L"LEFT");
And have the following questions:
- Is this safe? As my understanding this temporary object will be deleted when we exit of outer function/method.
- Why this is working? Does this mean that Construct() holds copy of this object?
- Can I pass object, created by new operator? And who should release memory of this object (allocated by new)?
And the same question about AddControl() function. Because to this one is passed object allocated by new operator.
Does this mean that
- I can't pass temporary object to AddControl() function?
- Framework will release itself "new"-allocated objects passed to the AddControl() method?