0

pointers

Can some one illustrate what is pointers and how to understand its funtion precisely. Thanks in advance.

9th Jun 2017, 5:04 PM
Rajkamal A V K
Rajkamal A V K - avatar
1 Respuesta
+ 1
A useful example is something like a graph, where you have nodes interconnected. Each node will have a next and previous node, but you dont want to copy the node into the prev and next node, because in that way, changes made to the previous node will not affect the original node which is connected to it. So you need to store exactly that node, to be able to make changes to it from another node. Thats where you store the address of the node. That way the changes made to it will affect the original previous node. Also, a pointer is just 4 or 8 bytes(depending on 32 or 64 bits) so it takes less memory to store a pointer than almost every custom class.
9th Jun 2017, 6:41 PM
Madera Oxidada
Madera Oxidada - avatar