I can write a function this way in objective C. This can be used to churn out many UIButtons.
+(UIButton*)getButton:(CGRect)frame{
UIButton *button=[UIButton buttonWithType:UIButtonTypeRoundedRect];
[button setTitle:@"Some title" forState:UIControlStateNormal];
button.frame=frame;
return button;
}
Can the same be done in C++. I am not asking about creation of UIButton in C++.
But churning out many objects with a help of a function as this:
CString getCstring(some parameters)
{
CString string = L"Hi sampe string.";
return string;
}
I think that the CString object that is created in this function would be in stack and may lose it value once goes out of this function.
In case of Objective C code, we can retain the autoreleased object to use it. Is there any such mechanism available in C++?