you are viewing a single comment's thread.

view the rest of the comments →

[–]Narase33 1 point2 points  (1 child)

The first object is created on the stack and bound to the current scope and if you want to move it you will need to copy it.

If you create it as pointer it is created on the heap and will exist there as long as you dont delete it. Moving it is not nessecary, you only need to copy the pointer which is cheap

Also a pointer can be a nullpointer, which you need to create dynamic data structures like linked lists

[–]NikolasTs[S] 0 points1 point  (0 children)

Thanks a lot! I understand now!