0

Pointers in c++

What is the advantage of using pointers instead of arrays?

28th Sep 2018, 4:00 AM
Jheniffer Gonsalves
Jheniffer Gonsalves - avatar
3 Answers
+ 1
What do you mean by "instead of arrays"? Arrays and pointers are closely related.
28th Sep 2018, 7:14 AM
Matthias
Matthias - avatar
+ 1
Jheniffer Gonsalves Sorry if I didn't really get what you meant. Yes, you can use the array syntax instead of pointers to declare a static array, or to traverse an array. Which one is better? Matter of preference, I would say. Can an array be used to traverse a container? No. A linked list? No. Managing memory? No. Reference to dynamically allocated memory? No. All of those things, and many more, can be done with pointers.
28th Sep 2018, 9:37 AM
HoĂ ng Nguyễn Văn
HoĂ ng Nguyễn Văn - avatar
0
yes. But I can write my code without using pointers. Just arrays. Because c++ will considere it a pointer when necessary. Right? Or I can write it using explicitly pointers. Is there a difference betweeen the 2 ways?
28th Sep 2018, 8:11 AM
Jheniffer Gonsalves
Jheniffer Gonsalves - avatar