Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.dougwise.org!gegeweb.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: calling own methods from constructor Date: Thu, 07 Apr 2011 20:59:36 -0400 Organization: A noiseless patient Spider Lines: 28 Message-ID: References: <2011040622233261380-angrybaldguy@gmailcom> <455e7ffb-369e-4d88-912e-01581c7cbfb5@bl1g2000vbb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 8 Apr 2011 00:59:42 +0000 (UTC) Injection-Info: mx03.eternal-september.org; posting-host="KiwfXDyOjqGhZBXcfNnZBg"; logging-data="2606"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19zvZyY8vpTJXCvi0VtcXuD" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 In-Reply-To: Cancel-Lock: sha1:ZSh7t5L8FaODxUuktIOygo2yL2Q= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:2962 On 4/7/2011 3:00 PM, Tobias Blass wrote: > 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. (struct tm)42; -- Eric Sosman esosman@ieee-dot-org.invalid