RE: [Dev-C++] Why doesn't this compile?
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Ioannis V. <no...@ho...> - 2002-10-09 23:08:19
|
> -----Original Message----- > From: dev...@li...=20 > [mailto:dev...@li...] On Behalf=20 > Of Andrew Vidler > Sent: Wednesday, October 09, 2002 6:36 PM > To: 'C++ Dev' > Subject: RE: [Dev-C++] Why doesn't this compile? >=20 >=20 > Absolutely. Sorry, I'm probably not being very clear :) > MY_TYPE *p =3D *c > Does work, problem is, what I'm looking for is some operator=20 > that does: > MY_TYPE *p =3D c; >=20 > I don't think this is possible...but you never know! Ok you have confused things. Forget the whole thing completely. Just do: // Example #define MY_TYPE int CBase *c =3D new CDerived; If you want to point to it using some pointer of entirely foreign type, this means you must know what you are doing and use a cast (in your case the ugliest of all, reinterpret_cast). MY_TYPE *f =3D reinterpret_cast<MY_TYPE *>(c); Forget those operators you were using. Ioannis * Ioannis Vranos * Programming pages: http://www.noicys.freeurl.com * Alternative URL: http://run.to/noicys |