Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!usc!apple!vsi1!ubvax!weitek!practic!vlsisj!davidc From: davidc@vlsisj.VLSI.COM (David Chapman) Newsgroups: comp.lang.c++ Subject: Re: private/protected/public implementation Summary: only within the compiler Keywords: compiler, keywords Message-ID: <15447@vlsisj.VLSI.COM> Date: 18 Jan 90 04:19:44 GMT References: <626@watserv1.waterloo.edu> Reply-To: davidc@vlsisj.UUCP (David Chapman) Distribution: comp Organization: VLSI Technology Inc., San Jose, CA Lines: 23 In article <626@watserv1.waterloo.edu> mgardi@watserv1.waterloo.edu (Mutual Life) writes: >Could someone give me a short description of how the compiler restricts >access to private/protected elements? > >When I look at the C code generated, I don't see any difference in >the code regardless of where I place the data. It should look the same because (presumably) you're doing the same thing in each case. If you try to access elements without the "privilege" to do so, the compiler simply refuses and prints an error message. This checking doesn't get out to the generated C code (with cfront as opposed to native compilers like Zortech) because you aren't modifying that file. At least I hope you're not. :-) The "prevention" is done by the compiler at compile time and has no effect at run time. You can still do just as much damage as with C. :-) -- David Chapman {known world}!decwrl!vlsisj!fndry!davidc vlsisj!fndry!davidc@decwrl.dec.com