Hello Everyone ,
I am confused regarding calls to Base Class constructor from an Extended Class Constructor .
Normally when we call a Constructor the LHS is seen as to whose constructor needs to be Called .
(I) what about the LHS of super.new() ? . Since there is No return type in a Constructor , we don’t a warning when there is no left hand side of super.new()
Passing an object handle to a method as ref argument VS as an input argument
when handle is passed as ref the address of the variable is passed so that modifications made inside the method are reflected back.
(II) what happens when its passed as an input argument . what gets passed to the method ? Since we can access the objects properties inside the method , but when the properties or Object is modified the change isn’t reflected back ?
I have following lines from a deep copy function ::
// In extended Class Ext
virtual function Base copy ( input Base b1 = null); // Signature Same as Base Class virtual copy function
Ext e1 ; // Ext is extended class
if ( b1 == null )
e1 = new();
else
$cast(e1,b1); // Downcasting else I would compilation error
super.copy(e1) ; // (a)
// Assign extended class property
e1.new_property = this.new_property ;
return e1 ; // returned type is different that the function prototype
(III) In statement (a) I get a warning of Implicit void cast. What should be the LHS during call to super.copy() ?
(IV) How would the above extended class method be called from outside the class ?
**(V)return type of method is Base whereas we actually return ext type object . So is it necessary to use downcast during call to extended class copy function ?
**
Thanks in advance ,
HV