I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?

By drakula david in 22 Sep 2023 | 12:36 pm
drakula david

drakula david

Student
Posts: 128
Member since: 22 Sep 2023

I want my class to be developed in such a way that no other class (even derived class) can create its objects. How can I do so?

22 Sep 2023 | 12:36 pm
0 Likes
divas goyal

divas goyal

Student
Posts: 453
Member since: 22 Sep 2023

To prevent other classes from creating objects of your class (including derived classes), you can make the class's constructor `private`. This restricts object creation to within the class itself.


23 Sep 2023 | 04:06 pm
0 Likes

Report

Please describe about the report short and clearly.