Link to home
Start Free TrialLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

pointers, references and variables in any language

Please explain the diffenence between pointers, references and variables

This is a python example but the pointers, references and variables is in c++, so I can not test
https://www.experts-exchange.com/Programming/Languages/Scripting/Python/A_6589-Python-basics-illustrated-part-2.html

Is there a way I can test.
For example w3schools.com makes it easy to type in code into a text editor
ASKER CERTIFIED SOLUTION
Avatar of dpearson
dpearson

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

so reference is storage space of a variable value

and pointer is storage space of a reference value?
Avatar of pepr
pepr

Reference in the abstract sense is the value that refers to the target object (where the object can be as simple as an integer variable). The concrete implementation of a reference is the address of the target stored in another variable (speaking about compiled languages as C++, for example). If that dereferencing is done automatically, then it looks as if the extra variable did not exist and as if one worked directly with the target object. But it is only the illusion -- the access is indirect. If the dereferencing is done explicitly, then we call it a pointer.

When speaking about a pointer, we can think about both the pointer variable and the address of the target stored inside. We can think this way also when thinking about a reference. However, a reference usually mimics the target object so well that some people tend to think about it (incorrectly) as about the target object itself.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgb192

ASKER

thanks for all advice.
I am starting to understand.