pointers, references and variables in any language differences

I do not understand long articles about differences between variables, references, pointers



But those that do support references always require that the reference is always filled with value to some existing objects (i.e. some address). Pointers on the other hand can contain a special value named nil, NULL, nullptr or the like that says "pointing to nowhere".

so now I know one difference between pointer and reference

Are there any other differences without an long explanation that I do not understand yet.
LVL 1
rgb192Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Probably not.  While those are generic computer science terms, for any specific language you will still need to know and understand the details of how they implemented it.
0
phoffricCommented:
>> references always require that the reference is always filled with value to some existing objects (i.e. some address

It may be filled initially, yet if the block holding the object being referenced is completed (e.g., a function returns), then the reference will be referring to a non-existing item. (This is similar to a non-null pointer problem, but I mention this because the above quote may be misinterpreted.)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HooKooDooKuCommented:
A reference and a pointer are pretty much the same thing under the hood.  When you pass an object by reference or by pointer, the compiler still passes a pointer.  It's just the compiler takes care of de-referencing the pointer for a reference variable, but you have to take that extra step when dealing with a pointer.

But the other difference is that a reference variable always has to be assigned to a valid object.  By contrast, a pointer can point to anything (bad memory location) or to nothing (NULL Pointer).
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

phoffricCommented:
Please post a quote of something that you do not understand in those articles.
0
peprCommented:
There are always two sides: a machine and a man. Programming language is in between. The language has syntax (how it is written) and semantics (what does it mean). The processor uses the address of the memory space to get there. This is actually the meaning of both using the pointer variable and also of the reference variable. But it looks differently when written in a programming language.

In Python and in Java, you can use only references. There are no pointers. C++ is more rich in syntactic sense -- you can also use the more complex, more low-level, less restricting, bit also more difficult (more error-prone) pointer approach.

To understand the difference, you need to learn and compare the examples in the language that allows both. I suggest C++. Study:

1) working with a simple variable,
2) working with the variable through a reference variable,
3) working with the variable through a pointer variable.
0
rgb192Author Commented:
generic computer science terms
reference is always filled with value to some existing objects and pointer can point to null
The processor uses the address of the memory space to get there. This is actually the meaning of both using the pointer variable and also of the reference variable.

Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Python

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.