Re: 2 initializers in 1 constructor

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions.com> wrote in
message news:Of9EMbmYHHA.984@xxxxxxxxxxxxxxxxxxxxxxx
Hi,

<narayanareddy.tera@xxxxxxxxx> wrote in message
news:1173432680.554454.51100@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Hi GeezerButler,

the dot not compiler does allow us to invoke 2 constuctors(whether the
two are of it's own or it's parent).you can invoke only one either
of it's own or it's parent.

No really, you have to invoke one of the constructor defined by the
current class, is this constructor the one that call the parent.

Here the reason is, if it allows then 2 objects of that class will be
instantiated (one by each constructor invoke) .one of the two objects
would become unreached oblect.

I do not understand the above sentence, do you care elaborate it further?

When you call a sibling constructor, it calls a base constructor. If you
called the base constructor again yourself, you'd now have two live
instances of the base class (possibly the second overwrote the memory of the
first). In any case, the derived class should only have one base
sub-object, the other would become unreachable.


.



Relevant Pages

  • Re: Dynamic inheritance
    ... >> to invoke the development portion of the IDE to modify the tree and ... > That's not the case in Smalltalk, ... properties at run time when the constructor is invoked. ... repository, modify the tree with the existing IDE tools, and then let ...
    (comp.object)
  • Re: Calling a constructor from another
    ... instantiated is a composite of all the properties in all classes in the direct line of ascent in the subclassing tree, the usual technique is to provide a constructor for each class to handle that class' properties and invoke them in a nested fashion. ... While using the Factory pattern ... the method responsibilities they need to invoke constructors. ...
    (comp.object)
  • Re: Detecting wich method was called in a WS contructor
    ... It's true there is a pending invocation of a webmethod when the constructor ... Callers invoke ... > of Web Services, so I created a couple of standard classes in order to ...
    (microsoft.public.dotnet.framework.webservices)
  • Re: Invoke a superclass method from a subclass constructor
    ... An instance of my subclass doesn't invoke its superclass method, ... In B's constructor, you create a new instance of A (a pointless ... use its "super" function as an excersise to the reader. ...
    (comp.lang.python)
  • Re: Invoking delegates in a base constructor
    ... That won't work because since you're calling the base constructor explicitly ... the base class is executing in it's own object space ... Initialize() gets called in the base. ...
    (microsoft.public.dotnet.framework)