@broadblues
No it should not take infinity memory.
Remember the classes are created when they are called.
Normally you create a method that return the same class.
Class MyA()
{
public:
MyA()
{
printf(“created\n”);
}
~MyA()
{
printf(“deleted\n”);
}
MyA Magic()
{
MyA temp;
return temp;
}
}
int main()
{
MyA test;
test.Magic();
}
this is small example, what will happen is test is created, when main() is called.
Next when method Magic is called, MyA Temp is created, value is returned, and temp is deleted,
and when main() ends, test is automatically deleted..
created objects are handled by the language, how ever if you do a New MyA() its not deleted (at least that's what I believe).
I the case where MyB was private or public object whit in MyA, and MyA where private or public object whit MyB, then you be right, but in this case its created only whit in the methods.