The Microsoft memory-model specifiers for function arguments and for the this pointer are used for disambiguation between overloaded functions. The following two functions are considered different because the arguments use different addressing:
char *strchr( char *szString, char chTarget );
char *strchr( char __far *szString, char chTarget );
This functionality enables different implementations, depending on the addressing specified. Similarly, the member functions in the following class fragment are different because the this pointer is overloaded:
class __far List
{
public:
List() __far; // This class is intended to be far.
List() __huge; // The near and huge constructors simply
List() __near; // issue run-time error messages.
...
protected:
void AddressingError( char *szModel );
};
List::List() __far // Correct instantiation.
{
// Set up the list.
}
List::List() __near // Incorrect addressing.
{
AddressingError( "__near" );
}
List::List() __huge // Incorrect addressing.
{
AddressingError( "__huge" );
}
// Issue error message.
inline void AddressingError( char *szModel )
{
cerr << "Cannot create a << szModel
<< " instance of a List.\n"
}
In the preceding example, the functions List::List() __far, List::List() __near, and List::List() __huge, are considered different because of the overloaded this pointer.