+ 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?
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
+ 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
+ 2
Tarika I learned that lesson I now understand
+ 2
I learned polymorphism just now and they're not useless for me anymore tysm
+ 2
access a variable from another using pointer...
+ 1
So what is a good use for it?
+ 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.
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.
0
can we access a variable from another project using pointer?