+ 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
7 Antworten
+ 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.
+ 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
+ 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++
+ 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 🖇️🔗
+ 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
+ 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 :)
0
https://www.sololearn.com/discuss/84131/?ref=app
https://www.sololearn.com/discuss/514500/?ref=app
https://www.sololearn.com/discuss/702383/?ref=app
https://www.sololearn.com/discuss/1781629/?ref=app
https://www.sololearn.com/discuss/1481630/?ref=app
https://www.sololearn.com/discuss/1813394/?ref=app
https://www.sololearn.com/discuss/199279/?ref=app
https://www.sololearn.com/discuss/1521991/?ref=app
https://www.sololearn.com/discuss/2333585/?ref=app
https://www.sololearn.com/discuss/1918410/?ref=app
https://www.sololearn.com/discuss/1452523/?ref=app
https://www.sololearn.com/discuss/1491177/?ref=app
https://www.sololearn.com/discuss/2296764/?ref=app
https://www.sololearn.com/discuss/1319819/?ref=app