Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!ai-lab!idsardi From: idsardi@wheaties.ai.mit.edu (Bill Idsardi) Newsgroups: comp.lang.c++ Subject: subclasses with missing members Message-ID: <2484@wheat-chex.ai.mit.edu> Date: 18 May 89 01:52:47 GMT Reply-To: idsardi@wheat-chex.ai.mit.edu (Bill Idsardi) Organization: The MIT AI Lab, Cambridge, MA Lines: 37 References: In reading a book recommended in this newsgroup recently (Ira Pohl: C++ for C Programmers), there is a discussion of a class, student, and an inheriting subclass, grad_student, (pp 147ff): enum year {fresh, soph, junior, senior}; enum support {ta, ra, fellowship, other}; class student { protected: int student_id; float gpa; public: ... year yr; ... } class grad_student : public student { support s; public: ... } My question is: Is there a (simple) way to cause grad_student to fail to inherit the data member yr from student? Another example of this would be a class of quadrilaterals and a subclass of squares. We might have 4 members representing side lengths in quad, but only need 1 side length in square. A similar point could be made about angles. The obvious way is to invent an abstract class from which student and grad_student would inherit. Is there a better way? Bill Idsardi MIT