Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!apple!agate!forney.berkeley.edu!jbuck From: jbuck@forney.berkeley.edu (Joe Buck) Newsgroups: comp.lang.c++ Subject: Re: For Philosophers and Lawyers Message-ID: <1991May24.012020.9980@agate.berkeley.edu> Date: 24 May 91 01:20:20 GMT References: <519f23cc.19260@apollo.HP.COM> <72535@microsoft.UUCP> Sender: root@agate.berkeley.edu (Charlie Root) Reply-To: jbuck@forney.berkeley.edu (Joe Buck) Organization: University of California, Berkeley Lines: 30 This thread addresses problems with casts between pointer types that are declared (i.e. "class A;") but not defined, and the problems that arise with multiple inheritance. Jim Adcock points out that >C++ allows these unsafe casts so that programmers can use pointers to >objects without always having to include class declarations. This is a very strong argument; those of us that want our large C++ projects to compile in reasonable time rely on incomplete class declarations. Also, E&S discusses this very issue on pp. 68-69. They give the example class S; class T; T* f(S* p) { return (T*)p;} class A { int a;}; class S { int s;}; class T : public A, public S { int t; }; This code will do The Wrong Thing. Their conclusion? "It follows that where multiple inheritance is involved casting to and from undefined types is best avoided." -- Joe Buck jbuck@galileo.berkeley.edu {uunet,ucbvax}!galileo.berkeley.edu!jbuck