+ 1
With the help of a suitable program discuss pointers can be helpful in programming
4 odpowiedzi
0
It can be usefull storing the memory address of variables because you get access to the heap memory, you can avoid copying values(which can take a lot of time) and you are also saving a lot of memory storage (considenring that memory is limited).
For example lets say that you have an array of 1000 car objects (let's say that this object has a size of 100 bytes). But you want to make another array which stores only these cars that are grey(250 of these cars are actually grey).
One solution would be to start copying everysingle one of these in a new array of 250 elements. That would not only take a long amount of time, but the size of the new array would be an extra 25KB.
The other solution would be to store in an array pointers to each grey car. That would take far less time(copying just memory adresses) AND the size of the new array would only be 1KB (a pointer is an integer so it is 4bytes per pointer)!
0
Kindly write the program
0
Brian Bor, I just explained to you a common situation, why do you need the programm in order to understand?