sher@sunybcs.uucp (David Sher) (03/10/89)
Is there any reason why functions can be virtual but not data objects (the implementation of a virtual data object is exactly analogous to that of a virtual function). Here's the application: I have a matrix package with two types of matrices and vectors. A vector is the base class is what you'd expect. A spaced vector is a vector which is not contiguous in memory but is every nth element where n is given. Similarly I have matrix and spaced matrix. So a row of a matrix is a vector. Thus I can define class matrix {... virtual vector *rows; // the rows of the matrix ... }; I also want to say: class spaced_matrix {... virtual spaced_vector *rows; ... } Currently c++ does not support this but I would think that this would increase the orthogonality of the language, the efficiency of implementing things like this (which would seem to be a fairly common effect the elements of a complex subclass would be sub classes) and generally a trivial to implement improvement. Adding it would not break anything I can imagine and in fact should simplify the compiler considerably. -David Sher -David Sher ARPA: sher@cs.buffalo.edu BITNET: sher@sunybcs UUCP: {rutgers,ames,boulder,decvax}!sunybcs!sher