* (e-mail address removed):
I require a single c++ program that will illustrate usage of
this,far,near pointers. Can any body please explain me those pointers?
'this' is part of standard C++. Within a member function it's a pointer to
the object the member function has been called on. So when you write
o.foo();
then within 'foo', for this execution, 'this' will point to the object 'o'.
'far' and 'near' are non-standard extensions. They were used in C and C++
on 16-bit DOS and MS-Windows platforms. There a 'near' pointer was a 16-bit
offset into a region of memory, with implicit start address (the implicit
start address depended on the context, which made this optimization a risky
business -- whole books have been written about it). 'far' was a 32-bit
pointer consisting of a 16-bit 'selector' that indirectly determined the
start address of the memory region, and a 16-bit offset into that region.
Today few, if any, C++ compilers support 'far' and 'near'. In modern 32-bit
Windows (say, this is actually mostly independent of modern OS) a pointer is
usually just a 32-bit offset into a region of memory. Since data and
function pointers are two different kinds of beast in C++ it's theoretically
possible that a function pointer may be an offset into a different region of
memory than a data pointer, but in practice that's not so. Anyway, the
hardware may support larger pointers; e.g., the processor in a Windows/Intel
PC supports 48-bit pointers consisting of a 16-bit 'selector' and a 32-bit
offset, but ordinary C++ compilers don't support such 48-bit 'far' pointers.
Now, region of memory. I've used that above to refer to the process'
_logical_ address space. On modern computers logical addresses will usually
be translated by the OS and hardware to physical addresses, so C++ pointers
are usually not directly memory addresses, and the address space they refer
to is usually not a contigous region of physical memory.
However, on a microcontroller, say, a C++ pointer can be a physical memory
address.