+ 4
Pointers(need help)
What's the use of pointers in c++? Where are they used? Any examples if possible?
3 Respostas
+ 3
when we use a variable, we first see it's memory address, and then perform the action on it.
with pointers, we directly perform the operation on the memory address, hence saving us a step and making the execution faster.
also, pointers and arrays are like brothers. you need pointers if you want to pass around arrays in and out of a function.
+ 2
oh I get it, its for speed. thanks
+ 1
It is not only to speed up. You need it for dynamic programming (dynamic memory allocation) and low level memory manipulations. Arrays are just pointers, so pointers are a deep concept in C and C++. You rarely need them but with pointers you can do difficult tasks with lesser code.