Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Tobias Blass Newsgroups: comp.lang.java.programmer Subject: Re: calling own methods from constructor Date: Thu, 7 Apr 2011 19:00:46 +0000 (UTC) Organization: A noiseless patient Spider Lines: 21 Message-ID: References: <2011040622233261380-angrybaldguy@gmailcom> <455e7ffb-369e-4d88-912e-01581c7cbfb5@bl1g2000vbb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Injection-Date: Thu, 7 Apr 2011 19:00:46 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="RMN3ouwFys9bx3aIdUo62A"; logging-data="6717"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ucyXM0XKawi3/blGUvJ7maNIeAGXIXak=" User-Agent: slrn/0.9.9p1 (Linux) Cancel-Lock: sha1:j68HQMYZSGXfOTxP77GO1HWEgRY= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2940 On 2011-04-07, Alessio Stalla wrote: > On 7 Apr, 14:19, Andreas Leitgeb > wrote: >> Casting in C++ is something different than in Java. >> Although, if you really do C, not C++, then it's it's >> much more like Java, except for the lacking safety net. > > I don't know about C++, but in C casting is not like Java at all. In > Java a cast is a runtime operation that checks the type of some object > (I'm not considering primitives). Of course the compiler knows about > it and uses it at compile-time too for type checking, but that's > somewhat a consequence of the previous point. In C, instead, casting > has no(*) runtime behavior; it's just an instruction for the compiler: > "please consider this datum to be of this type". If the compiler > accepts your order, it will blindly treat that datum as if it's of the > type you told it is, even if at runtime it's not. > > (*) actually, it might perform conversions in certain corner cases, > but still no runtime type check is ever done. Is there any case where the C compiler rejects casts? I cannot imagine an example.