"Kench" <no**@none.com> wrote in message
news:cb*********@kcweb01.netnews.att.com...
I was curious and playing with pointers and references to see what's
different between them.
Other than the obvious ones involving C++ syntax & things like references
cannot be modified with addition & subtraction,
pointers can be modified, both are similar.
It stated me going what are the diferrence between a reference vairable
and local variable ?
Here are what I can think of
1. For a local variable constructor is called, not the case for a
reference variable.
2. Local variable cannot be NULL. Reference variable can point to a NULL
object by a simple trick like. Employee* e = NULL; Employee* ref = *e;
Anything else?
I'm puzzled why you're using the term "local" at all. The term "local
variable" indicates a variable declared in local scope, i.e., inside a
function. That has nothing to do with the type of variable (i.e., built-in,
user-defined, pointer, or reference).
Also, you refer to a reference, but your example (Empoyee*) is a pointer.
Which did you mean?
Given these discrepencies, I won't comment on your points, because they
don't make sense without my making assumptions about what I *think* you
meant. Your best bet is to read a good C++ book. There should be plenty of
information about pointer-type variables and reference-type variables. Then
come back here and we'd be glad to help clear up any specific points, once
you have the terminology correct so we know what you mean.
-Howard