C++ POINTERS | Sololearn: Learn to code for FREE!

0

C++ POINTERS

Hi, I wanted to ask a couple of questions about some things I didn't understand about pointers in c ++. 1) What are they for, and if you can give me examples of programs, where pointers are necessary; 2) If they are useful in 2020; 3) When for example in the C ++ code I declare a variable like *p = &a. This contains the memory address of the variable 'a', and I wanted to know if this address (I HAVE USED VISUAL STUDIO), is that of the memory of my computer or one chosen at random from visual studio; I sincerely thank anyone who will help me solve this problem

12/19/2020 8:40:37 PM

Hammad Yaqub

4 Answers

New Answer

+4

This is simple program using pointers https://code.sololearn.com/cLheKuoZD23h/?ref=app Hope it helps you

+3

For example, if we are making dynamic array, and we want user to declare size of it int a; cin >> a; int tab[a]; Code above will result in error. We need to use pointer instead of tab[a] like this: int * tab = new int[a] ; There are plenty of examples on how useful pointers are, you can just type in browser for "pointers usage"

+2

pointer is a base in c++. they are used everywhere!!!

+1

ok thanks