Specifications
CAVR-4
Part 1. Using the compiler
Using C++
113
Note: Whenever a class type associated with a class memory type, like C, must be
declared, the class memory type must be mentioned as well:
class __far C;
Also note that class types associated with different class memories are not compatible
types.
There is a built-in operator that returns the class memory type associated with a class,
__memory_of(class). For instance, __memory_of(C) returns __far.
When inheriting, the rule is that it must be possible to convert implicitly a pointer to a
subclass into a pointer to its base class. This means that a subclass can have a more
restrictive class memory than its base class, but not a less restrictive class memory.
class __far D : public C { // OK, same class memory
public:
void g();
int j;
};
class __near E : public C { // OK, near memory is inside far
public:
void g() // Has a this pointer pointing into near memory
{
f(); // Gets a this pointer into far memory
}
int j;
};
class __huge F : public C { // Not OK, huge memory isn’t inside
// far memory
public:
void g();
int j;
};
class G : public C { // OK, will be associated with same class
// memory as C
public:
void g();
int j;
};
A new expression on the class will allocate memory in the heap residing in the class
memory. A delete expression will naturally deallocate the memory back to the same
heap.