Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!ncar!boulder!sunybcs!sher From: sher@sunybcs.uucp (David Sher) Newsgroups: comp.lang.c++ Subject: Why no virtual data? Message-ID: <4606@cs.Buffalo.EDU> Date: 9 Mar 89 18:53:58 GMT Sender: nobody@cs.Buffalo.EDU Reply-To: sher@cs.Buffalo.EDU (David Sher) Organization: SUNY/Buffalo Computer Science Lines: 30 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