keffer@SPERM.OCEAN.WASHINGTON.EDU (Tom Keffer) (07/26/89)
//The following code is from Stroustrup, p. 197. If you believe in God,
//it should compile.
//It involves manipulating private base classes through pointers.
class base {
int m1;
public:
int m2;
};
class derived : base {
};
main(){
derived d;
base * pb;
pb = (base*)&d; // Explicit conversion
}
Gives the following error (g++ 1.35.0; Sun3; SunOS 3.5):
In function int main ():
junk.cc:19: type `derived' is derived from private `base'
---
Dr. Thomas Keffer | Internet: keffer@sperm.ocean.washington.edu
School of Oceanography | BITNET: keffer%sperm.ocean.washington.edu@UWAVM
Univ. of Washington, WB-10 | uucp: uw-beaver!sperm.ocean.washington.edu!keffer
Seattle, WA 98195 | Telemail: T.KEFFER/OMNET
(206) 543-6455