+ 1

In which cases will the poiner be in use?

21st May 2019, 12:13 PM
sayeed
sayeed - avatar
4 Respostas
+ 3
E.g. when you want to change the value of an object or variable inside a function.
21st May 2019, 1:32 PM
Sonic
Sonic - avatar
+ 1
Well whenever you have to handle objects (or at least a large amount of them) and need to manage memory efficiently (object deletion, ...)
21st May 2019, 12:48 PM
ThewyShift
ThewyShift - avatar
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
21st May 2019, 3:06 PM
ThewyShift
ThewyShift - avatar
0
Good examples are LinkedList, ArrayList and Trees. You can store data efficiently.
21st May 2019, 5:12 PM
Tabea
Tabea - avatar