Path: csiph.com!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: How to assign an object to another in it method? Date: Mon, 3 Jul 2017 22:04:41 -0400 Organization: Aioe.org NNTP Server Lines: 30 Message-ID: References: <46334961-cc18-491f-828c-32e7401c7832@googlegroups.com> NNTP-Posting-Host: PBuS014lhzVyHjLbXmo/ZQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Language: en-US Xref: csiph.com comp.lang.java.programmer:36802 On 7/3/2017 10:04 AM, Andreas Leitgeb wrote: > Arne Vajhøj wrote: >> That is what I consider the missing default parameter issue. >> // **** NOT JAVA **** >> public Demo(String name, int answer = 6, boolean prisoner = false) > > Imho this is one thing that Java actually got right, by *not* supporting. > > In C++, default values can give a hard time when overiding methods with > defaults, as the default value depends on the static target object > type even for virtual methods. Yes. But is that really a problem? It seems like what one would expect. And changing the default value when overriding should be documented rather well as it is a somewhat suspicious thing to do. I hope that a static code analysis tool create warnings about doing something like that. Arne