0

What is the use of pointers in c++?

in c++ pointers store the address or location of variable but what exactly can we do with pointers like to create a game or any software do we actually need pointers?.but most of the languages don't even have pointers! so what can we do with the variables location?

12th Oct 2018, 10:03 AM
Sainath Dora
1 Odpowiedź
+ 2
When you pass an argument to a function, like myfunc(3);, then a copy is made. For a little int that's no problem, but if you pass a larger object like an array, that can slow things down. By passing a pointer to the beginning of the array, you only make a copy of the address instead of the whole thing. Basically, instead of driving a truck filled with stuff to your function's front door, you just hand over a paper: "Get your stuff at this address!"
12th Oct 2018, 11:33 AM
HonFu
HonFu - avatar