Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!brutus.cs.uiuc.edu!wuarchive!gem.mps.ohio-state.edu!rpi!batcomputer!cornell!uw-beaver!mit-eddie!mit-amt!peter From: peter@mit-amt.MEDIA.MIT.EDU (Peter Schroeder) Newsgroups: comp.lang.c++ Subject: question regarding derivation Keywords: derivation,public/protected/private Message-ID: <681@mit-amt.MEDIA.MIT.EDU> Date: 8 Sep 89 19:09:20 GMT Organization: MIT Media Lab, Cambridge, MA Lines: 50 Consider the following example of derivation. I was under the impression that `val' would be visible to member functions of the derived class cvect because it is protected in vect. Sure enough cfront 1.2 does compile it as expected, however to get it to compile under g++ (1.35.1-vax) I need to insert the commented out lines in the derived class. Who is correct? class vect{ protected: double val; public: vect() { val = 0; } vect( double d ) { val = d; } vect( vect& a ) { val = a.val; } vect& operator=( vect& a ) { val = a.val; return *this; } vect operator+( vect& a ) { return vect( val + a.val ); } }; class cvect : private vect{ private: cvect( vect& v ) : ( v.val ) {} // uncommenting the following two lines makes things work under g++ // protected: // vect::val; public: cvect() : () {} cvect( double d ) : ( d ) {} cvect( cvect& cv ) : ( cv ) {} cvect& operator=( cvect& cv ) { return vect::operator=( cv ); } cvect operator+( cvect& cv ) { return vect::operator+( cv ); } }; main() { cvect v0, v1( 2 ); v0 = v0 + v1; } Your comments would be much appreciated! Peter peter@media-lab.media.mit.edu