Rationale behind constructor call chain... ( and comparison with C++)
- From: "A.B." <ab2@xxxxxxxxxxxxxxx>
- Date: 30 Oct 2006 13:56:25 -0800
Just a question...
If an object B extends an object A, whenever B is constructed, A is
constructed... if A() calls a
function that is overloaded in B, it looks like the overloaded function
is called by the A constructor ...
( In C++ the behavior is always to call the function defined in A when
called within the A constructor, even if the overloaded function is B
is virtual. )
Can someone explain me the rationale behind java's behavior in that
case, how it's useful, more logical etc than the C++ approach... can
this behavior be overriden?
Thanks!
.
- Follow-Ups:
- Re: Rationale behind constructor call chain... ( and comparison with C++)
- From: Eric Sosman
- Re: Rationale behind constructor call chain... ( and comparison with C++)
- From: andrewmcdonagh
- Re: Rationale behind constructor call chain... ( and comparison with C++)
- From: Thomas Hawtin
- Re: Rationale behind constructor call chain... ( and comparison with C++)
- Prev by Date: Re: Why Java's math expression (power) is so inconvenient and error prone?
- Next by Date: How to make display sleep (aka go off) in Java cell phone program
- Previous by thread: a problem in transfer a int to Object
- Next by thread: Re: Rationale behind constructor call chain... ( and comparison with C++)
- Index(es):