‎2015 Mar 10 10:00 AM
Newbie question....
In both super class and subclass i am using constructor.The problem is arising when i am creating objects.The main constructor is being initialized twice,once there when super class object creating and another due to mandatory addition of "super->constructor" in subclass constructor method.How can i make sure that the super class constructor does not initialize twice.
‎2015 Mar 10 10:20 AM
Make your superclass constructor as protected, now only your subclass can call the super class constructor & you cannot create object of superclass.
‎2015 Mar 10 10:34 AM
Hi Sharath
Tried but Constructor can't be declared in protected section.It is not possible.
This is a point in ABAP WORKBENCH TAW12 Part 1 book.
A constructor must be defined in the public area.
‎2015 Mar 10 10:52 AM
Till Release 7.0 EhP2, CONSTRUCTOR can only be declared as Public. From this release onwards, we can define the CONSTRUCTOR visibility also while defining the class.
‎2015 Mar 10 10:46 AM
Put condition on '' super->constructor '' in subclass constructor if you dont want to call it twice.
check if the super class object already created or set a flag if constructor already called.
Hope i solved your problem.