Hi,
i am not expert of C++, so i have this general question about C++. What is better, mem alloc or stack alloc?
That means:
auto o = Foo::Foo();
vs
auto o = new Foo();
?
I guess first is stack alloc, and second mem alloc. First uses dot notation, second uses arrow. (First returns the object(?), while the second returns the pointer to object)
I know, that for example deleting of mem object is like
delete o;
Not sure how is it with stack object.
Is there any difference in general? What is more recommended? Is it bad idea to return object from stack eg in custom class constructor? For example because, if there will be many objects created like this, there can be some stack overflow or so? Or any disadvantage too may be? I am not sure.
Eg like this:
TurnManager TurnManager::create(int turnTime)
{
auto tm = TurnManager::TurnManager();
return tm;
}
Thx,
L.
Ps, i am starring how much detail things there is in C++ 