Virtual Table Pointers

If a class uses virtual functions, the compiler builds an array of function pointers for that class. This array is known as a virtual function table, or a “v-table.” Every object of such a class contains a hidden member called a “v-table pointer.” When you call a virtual function for an object, your program uses that object's v-table pointer to find the v-table, and then looks in the v-table to find the address of the function that must be called.

Similarly, if a class inherits from a virtual base class, the compiler builds an array containing the offsets of the virtual bases. This array is called the virtual base displacement table, or “v-base table.” Every object of such a class contains a hidden member, called a “v-base table pointer.” When you access one of an object's data members that was defined by the virtual base, your program uses that object's v-base table pointer to find the v-base table and then looks in the table to find the offset of the virtual base.

Summary: V-table pointers' addressing mode is determined by the class memory model.

The addressing mode of these virtual table pointers is determined by the memory model of the class. The virtual tables of a near class are stored in the default data segment, and objects of that class have near virtual table pointers. The virtual tables of a far class are stored in an anonymous far segment in the TEXT group. Objects of far classes have far virtual table pointers. These characteristics cannot be overriden by specifying a memory model keyword in the declaration of an individual object.

You can use the /NV switch to specify the name of the segment in which the virtual tables are stored. For near classes, the segment specified must be one of the segments in DGROUP. For far classes, any segment can be specified.