Overloading the this Pointer

If the standard conversions do not allow your objects to be passed to member functions, you must overload the member functions on the addressing mode of the this pointer. To specify the addressing mode for a member function, place the __near, __far, or __huge keyword after its parameter list. For example,

class __near RecArray

{

public:

RecArray();

RecArray() __far;

void printNames();

void printNames() __far;

~RecArray();

~RecArray() __far;

private:

// ...

};

Now when you declare a far RecArray object, the far constructor is called. Similarly, if you call the printNames() member function for that far object, the far printNames() function is invoked.

The keyword (__near, __far, or __huge) following the function name describes the addressing mode of the this pointer within the member function. When you call a member function for an object, if the standard conversions can match your call statement to more than one function, the function with the best match is selected. You cannot declare a member function as having a based this pointer.

It is not required that you overload all the member functions on the this pointer. You only need to overload member functions that are called for objects that don't have the addressing mode specified for the class.