Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Why public constructor in abstract class?

Former Member
0 Likes
536

I am confused about a very basic thing.

Why must a constructor in an abstract class be public?

After all, it can only ever be called from the constructors

of the concrete subclasses, because of which I would

normally expect it to be protected.

-- Sebastian

1 ACCEPTED SOLUTION
Read only

naimesh_patel
Active Contributor
0 Likes
474

Yes, it is confusing.

But 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. So, till this release all CONSTRUCTOR methods are public, no matter what type of class installation it is (i.e. Abstract or Private).

Check this link: http://help.sap.com/abapdocu/en/ABENNEWS-71-ABAP-OBJECTS.htm#!ABAP_MODIFICATION_1@1@

Regards,

Naimesh Patel

1 REPLY 1
Read only

naimesh_patel
Active Contributor
0 Likes
475

Yes, it is confusing.

But 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. So, till this release all CONSTRUCTOR methods are public, no matter what type of class installation it is (i.e. Abstract or Private).

Check this link: http://help.sap.com/abapdocu/en/ABENNEWS-71-ABAP-OBJECTS.htm#!ABAP_MODIFICATION_1@1@

Regards,

Naimesh Patel