+ 4

What is the use of pointers?

A pointer in C++ just give us a boring hexadecimal number. I think this is useless. Does it have a use?

7th Jul 2018, 1:07 PM
🇹🇷HighFlyer🇹🇷
🇹🇷HighFlyer🇹🇷 - avatar
9 ответов
+ 10
Hello, HighFlyer ! A pointer is the same variable, only it is initialized not by the value of one of the many types of data in C++, but by the address, the address of some variable that was declared in the code earlier. We will analyze on an example: int main () { int val = 5; } By the way, you can always pay attention to this lesson from SoloLearn https://www.sololearn.com/learn/CPlusPlus/1630/?ref=app
7th Jul 2018, 1:22 PM
Alexander Sokolov
Alexander Sokolov - avatar
+ 2
Pointer have an GREAT use in C/C++ that you can understand only when know dynamic memory allocations, function/method argument passing, polymorphism and some others
7th Jul 2018, 2:13 PM
KrOW
KrOW - avatar
+ 2
Tarika I learned that lesson I now understand
8th Jul 2018, 6:35 PM
🇹🇷HighFlyer🇹🇷
🇹🇷HighFlyer🇹🇷 - avatar
+ 2
I learned polymorphism just now and they're not useless for me anymore tysm
8th Jul 2018, 7:38 PM
🇹🇷HighFlyer🇹🇷
🇹🇷HighFlyer🇹🇷 - avatar
+ 2
access a variable from another using pointer...
16th Jul 2018, 4:53 PM
Suraj Patil
Suraj Patil - avatar
+ 1
So what is a good use for it?
7th Jul 2018, 1:26 PM
🇹🇷HighFlyer🇹🇷
🇹🇷HighFlyer🇹🇷 - avatar
+ 1
that boring hexadecimal number is a address of variable, if you want to understand this learn 'pass by value' and 'pass by reference' concept.
8th Jul 2018, 4:00 PM
Tarika
Tarika - avatar
0
pointer is use to store the memory location of any variable means you can access the value of variable x by storing memory location of x variable to any pointer.
7th Jul 2018, 1:10 PM
Nitin Khambhala
Nitin Khambhala - avatar
0
can we access a variable from another project using pointer?
7th Jul 2018, 1:13 PM
🇹🇷HighFlyer🇹🇷
🇹🇷HighFlyer🇹🇷 - avatar