Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cornell!uw-beaver!teknowledge-vaxc!mkhaw From: mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) Newsgroups: comp.lang.c++ Subject: accessing base class protected members Message-ID: <26619@teknowledge-vaxc.ARPA> Date: 10 Feb 89 00:54:10 GMT Reply-To: mkhaw@teknowledge-vaxc.ARPA (Mike Khaw) Distribution: na Organization: Teknowledge, Inc., Palo Alto CA Lines: 50 In the following short C++ program, // test use of "protected" members class bottom { protected: int botint; public: int getbot() { return botint; } }; class higher : public bottom { protected: float hifloat; public: float gethi() { return hifloat; } friend void mumble(higher&); }; main() { higher bar; mumble(bar); } void mumble(higher& foo) { foo.hifloat = 2.718; // this is OK foo.botint = 3; // should this be allowed? return; } Oasys C++ rel. 1.2 complains: ... error: botint is protected Is the complaint valid? If so, why? Mike Khaw -- internet: mkhaw@teknowledge.com uucp: {uunet|sun|ucbvax|decwrl|ames|hplabs}!mkhaw%teknowledge.com hardcopy: Teknowledge Inc, 1850 Embarcadero Rd, POB 10119, Palo Alto, CA 94303