Topic: virtual function in class.


Author: checker@acf3.nyu.edu (Christopher Hecker)
Date: Wed, 29 Apr 1992 23:03:44 GMT
Raw View
>//The code produces some apparently unexpected output... (not abiding by
>//normal class rules).
>base arvar[2];
>   base val1;  derived val2;

You need to be careful when defining arrays of objects.  Because there is
only space allocated for a base, when you put a derived into the array
it gets `clipped' and only the base part is used.  This follows from the
assignment rules...see ARM p.79 and p. 297.

The array of pointers is a good workaround.

Chris