Path: utzoo!attcan!uunet!kddlab!titcca!sragwa!wsgw!socslgw!diamond From: diamond@csl.sony.JUNET (Norman Diamond) Newsgroups: comp.lang.c++ Subject: Re: Is this a compiler bug ? Summary: No, it's your bug Keywords: G++ Message-ID: <10022@diamond.csl.sony.JUNET> Date: 27 Jan 89 06:02:59 GMT References: <435@tnosoes.UUCP> Organization: Sony Computer Science Laboratory Inc., Tokyo, Japan Lines: 21 In article <435@tnosoes.UUCP>, tom@tnosoes.UUCP (Tom Vijlbrief) writes: > When compiling a file of the OOPS package, G++ (1.32) produced an > errormessage for the following function: > ((Date)*this).printOn(strm); // Error ! When you cast the result of *this, it is like assigning the result of *this to a temporary variable of type Date. When you give a command to a temporary variable and then have no further use for that variable, you don't accomplish much. > ((Date *)this)->printOn(strm); // No Error ! Aha. When you have sort of a temporary variable of type (Date *), it still points to your own instance. You then command your own instance to do something, and you get what you want. -- Norman Diamond, Sony Computer Science Lab (diamond%csl.sony.jp@relay.cs.net) The above opinions are my own. | Why are programmers criticized for If they're also your opinions, | re-inventing the wheel, when car you're infringing my copyright. | manufacturers are praised for it?