"Shraddha" wrote:
What is exactly a handle to an object?
There is no "exact" answer. "Handle" is not a C++ term.
It's usually used to mean an identifier for a dynamically-
allocated object. (Examples: windows, icons.) This is
in contrast to an "identifier" which usually refers to
statically-allocated objects. (Examples: controls in a
window template.)
Is it same as reference?
No. In C++ a "reference" is an "alias", or an alternate
name, for an object.
Example:
std::string & Name = status_object.IncomingFileRecord.name;
You can now write to status_object.IncomingFileRecord.name
like this:
Name = "qb_7309.icf";
Instead of having to write:
status_object.IncomingFileRecord.name = "qb_7309.icf";
Much neater!
(Not to mention passing arguments to functions by non-const
reference, which makes it a breeze to use one function to
alter variables in another function. VERY nice technique.)
I suppose a "handle" could be implimented using a reference,
but it usually isn't. In my compiler at work (CVI), handles
are ints. In another compiler I worked with (Visual C++),
handles are void*. In the compiler I use at home for making
system utilities (gcc) handles are not used. It varies.
--
Cheers,
Robbie Hatley
lonewolf aatt well dott com
triple-dubya dott tustinfreezone dott org