473,789 Members | 2,925 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what is difference between this,far,near pointer?

hello,
I require a single c++ program that will illustrate usage of
this,far,near pointers. Can any body please explain me those pointers?
regards,
rahul.

Jul 23 '05 #1
4 14201
ra*******@gmail .com wrote:
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 a pointer to the object for which a non-static member function
was invoked (couldn't you look it up in your favorite C++ book?)

Neither "far" nor "near" pointers are defined in C++ _language_, please
refer to the compiler documentation that describes them. They are not
any standard concepts, they represent extensions to the language.

V
Jul 23 '05 #2
ra*******@gmail .com wrote:
hello,
I require a single c++ program that will illustrate usage of
this,far,near pointers. Can any body please explain me those pointers?
regards,
rahul.

The "this" pointer is defined within non-static member functions and
refers to the object on which the member is invoked.

There is no such thing in the language as "near" or "far" pointers.
That was a disgusting crutch by poor compilers on arcane architectures.
Jul 23 '05 #3
* ra*******@gmail .com:
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.

--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 23 '05 #4

<ra*******@gmai l.com> wrote in message
news:11******** **************@ f14g2000cwb.goo glegroups.com.. .
hello,
I require a single c++ program that will illustrate usage of
this,far,near pointers. Can any body please explain me those pointers?
regards,
rahul.


Your confused between this, which is a pointer to an object (usually
attached to the object's non-static member functions) and far/near which are
obsolete addressing schemes.

Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
16247
by: CoolPint | last post by:
Can anyone clearly explain the difference between constant reference to pointers and reference to constant pointers? What is const int * & ? Is it a constant reference to a pointer to an integer? Or Is it a reference to a pointer to a constant integer? What is being constant in this case? The pointer or the integer being pointed? How about int * const & ? Is this a reference to a constant pointer to an integer? Or
125
14858
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from software giant such as Microsoft SQL Server, Oracle, and Sybase? Is PostgreSQL reliable enough to be used for high-end commercial application? Thanks
16
10401
by: Abhishek | last post by:
why do I see that in most C programs, pointers in functions are accepted as: int func(int i,(void *)p) where p is a pointer or an address which is passed from the place where it is called. what do you mean by pointing to a void and why is it done? Aso, what happens when we typecast a pointer to another type. say for example int *i=(char *)p; under different situations? I am kind of confused..can anybody clear this confusion by clearly...
4
1880
by: Harro de Jong | last post by:
(absolute beginner here, sorry if this seems basic) Section 7.10 of 'How to Think Like a Computer Scientist' contains this discussion of string.find and other string functions: (quote) We can use these constants and find to classify characters. For example, if find(lowercase, ch) returns a value other than -1, then ch must be lowercase: def isLower(ch):
2
3858
by: Amal P | last post by:
Hi, This is the program that i made to test the usage of inline function. I am using vc 6.0 compiler. Please see the below program. int NonInline( int a, int b ) { return ( a b )? a: b; }
10
10764
by: mkausalya | last post by:
hai experts can know about the use of far & near keywords in c lang
30
508
by: Bill Reid | last post by:
#define MAX_VALUES 64 typedef struct { unsigned value_1; double value_2; double value_3; double value_4; } VALUES; typedef struct {
10
3446
by: Ahmad Humayun | last post by:
Whats the difference between: char str1 = "wxyz"; char* str2 = "abcd"; I can do this: str2 = str1 but I can't do this: str1 = str2
5
6912
by: iceman19860106 | last post by:
hello everyone! what is the difference between NULL and 0 in C language?
0
9666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9511
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10200
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10139
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9020
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7529
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3701
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2909
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.