Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!psuvax1!rutgers!att!att!andante!alice!ark From: ark@alice.att.com (Andrew Koenig) Newsgroups: comp.lang.c++ Subject: Re: problem with ** and *& Message-ID: <20415@alice.att.com> Date: 9 Jun 91 21:48:25 GMT References: Reply-To: ark@alice.UUCP () Distribution: comp Organization: AT&T Bell Laboratories, Liberty Corner NJ Lines: 34 In article mfx@cs.tu-berlin.de (Markus Freericks) writes: > if a 'b' can be used in the same places as an 'a' and a pointer to b can > be used as a pointer to a; why doesn't this hold for a pointer to a > pointer to b?? Because you could break the type system if it did. For example: class A { /* stuff */ }; class B: public A { /* other stuff */ }; main() { A a; B* bp; A** app; // Suppose this were legal... app = &bp; // Then we could do this: *app = &a; // which would make bp point at "a". Then... B b; *bp = b; // Oops! We've clobbered memory } There are many slippery issues having to do with pointer conversions of this kind. Designing a workable type system is not easy. -- --Andrew Koenig ark@europa.att.com