+ 1
In which cases will the poiner be in use?
4 Respostas
+ 3
E.g. when you want to change the value of an object or variable inside a function.
+ 1
Well whenever you have to handle objects (or at least a large amount of them) and need to manage memory efficiently (object deletion, ...)
0
Well the case of function is a little more complicated.
Basically, to optimise memory usage, instead of giving a copy of the object to the function, like we would do for standard types like int, double,... We pass directly the object (kind of, as we in fact give the reference of the object which is a pointer to that object)
The function doesn't have to modify your object though. This can even be prevented in some languages like c++, using keywords like const
0
Good examples are LinkedList, ArrayList and Trees. You can store data efficiently.