Loosen Constructor super()/this() call restrictions
Howard Lovatt
howard.lovatt at gmail.com
Tue Mar 24 13:07:28 PDT 2009
I don't get the example. Is class B meant to be Bar? Can you clarify?
-- Howard.
On 23/03/2009, at 8:56 PM, Marek Kozieł <develop4lasu at gmail.com> wrote:
> 2009/3/23 Howard Lovatt <howard.lovatt at iee.org>:
>> A few notes:
>>
>> 3. You shouldn't be able to access super fields or any instance
>> methods before super.
>>
>> -- Howard.
>>
>>
>
> Can you ensure that ?
>
>
>
> class A {
> private Bar bar;
>
> public A(Bar bar) {
> setBar(bar);
> }
>
> protected void setBar(Bar bar) {
> this.bar = bar;
> }
> }
>
> class B extends A {
> private Bar bar;
> private Foo foo;
>
> public B(Bar bar, Foo foo) {
> super(bar);
> this.foo = foo;
> }
>
> protected void setBar(Bar bar) {
> this.bar = bar;
> this.foo = bar.foo;
> }
> }
>
> Will code have same effect when constructor will be :
> public B(Bar bar, Foo foo) {
> this.foo = foo;
> super(bar);
> }
>
>
> --
> Pozdrowionka. / Regards.
> Lasu aka Marek Kozieł
>
> http://lasu2string.blogspot.com/
>
> ______________________________________________________________________
> This email has been scanned by the MessageLabs Email Security System.
> For more information please visit http://www.messagelabs.com/email
> ______________________________________________________________________
More information about the coin-dev
mailing list