Why we use pointers in c++? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why we use pointers in c++?

15th May 2021, 5:47 AM
Avanish
Avanish - avatar
4 Answers
+ 3
Ciro Pellegrino 13 years of experience as an android developer? But first release of android device was on 23 September 2008 means 12 years ago. He must be super master of android development. I think he is 13 years old not 13 years of experience.
15th May 2021, 7:52 AM
A͢J
A͢J - avatar
+ 1
Thanks everyone
15th May 2021, 4:29 PM
Avanish
Avanish - avatar
0
to an Android programmer with 13 years of experience I can only answer that it is done to have a greater chance of introducing bugs in the code. 🤣
15th May 2021, 6:20 AM
Ciro Pellegrino
Ciro Pellegrino - avatar
0
One of the usages of pointer is that : When you pass a variable to another function and you do some expressions on it and you come back to main function and want to print this variable , it will give you the last value that variable has in main function. For example : #include <iostream> void s(int n ) {n *=5;} int main() { int n = 67; s ( n ) ; std::cout << n;// output is 67 } #include <iostream> void s(int &n ) {n *=5;} int main() { int n = 67; s ( n ) ; std::cout << n;//output is 67 * 5 }
15th May 2021, 6:52 AM
Mani_K_A