+ 1

pointer in c++

hi. I'm learning c++. I don't understand the function of the pointers. does it is important in c++? If yes can you explain pointers please

12th Oct 2021, 6:27 AM
NotBadPlayer
NotBadPlayer - avatar
7 ответов
+ 3
C++ pointers are easy and fun to learn. Some C++ tasks are performed more easily with pointers, and other C++ tasks, such as dynamic memory allocation, cannot be performed without them. As you know every variable is a memory location and every memory location has its address defined which can be accessed using ampersand (&) operator which denotes an address in memory. There are few important operations, which we will do with the pointers very frequently. (a) We define a pointer variable. (b) Assign the address of a variable to a pointer. (c) Finally access the value at the address available in the pointer variable. This is done by using unary operator * that returns the value of the variable located at the address specified by its operand. Pointers have many but easy concepts and they are very important to C++ programming. 
13th Oct 2021, 6:30 PM
Arun Jamson
Arun Jamson - avatar
+ 2
Yes its very important topic pointers are soul of c and cpp for better understanding you can refer freecode camp pointer topic search on YouTube its completely based for pointers topics
12th Oct 2021, 6:37 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
+ 2
Thank me later https://youtube.com/playlist?list=PL2_aWCzGMAwLZp6LMUKI3cc7pgGsasm2_ In case the above link doesn't work: Channel: mycodeschool Playlist name: Pointers in C/C++
12th Oct 2021, 6:55 AM
Rishi
Rishi - avatar
+ 2
Hey Rishi can you please share the link again or tell me channel name? Because in clicking the link it is saying can't load link 🖇️🔗
12th Oct 2021, 10:55 AM
Saurabh
Saurabh - avatar
+ 1
Saurabh Kumar Yadav See my above answer, I've updated it with the name of the channel and playlist. I don't know why the link is not working. I tried again and can't find out exactly why this is happening
12th Oct 2021, 11:26 AM
Rishi
Rishi - avatar
+ 1
Pointers in my opinion are very important to learn and understand. When first learning, They may seem redundant as you create a pointer and make it hold/point to a address of a variable. Why do this if we can just directly access our variable? In this case a pointer just for that sole reason wouldn't be a good use of it. A better use (more so needed) would be to use pointers when we need to dynamically allocate memory on the heap. The syntax goes as follows: typename* variableName = new typename int* ptr = new int; We are creating a int pointer here. Why? Because if we didn't, we wouldn't know where our newly dynamically allocated memory would be. This is a prime use for pointers. I know at first they may seem redundant and not useful but the more you dig into C++, there usefulness is shown. Don't give up, you'll get there :)
14th Oct 2021, 3:36 AM
Sickfic
Sickfic - avatar