Rommeo Posted January 16, 2018 Share Posted January 16, 2018 Hello, My first question is; if there is a class, and i dont want this class to be instantiated anywhere? How can i do this? What are the ways/keywords for this? My second question is; Are there type of classes that can't be instantiated? What are the names of these classes? Thanks in advance. Link to comment Share on other sites More sharing options...
kicken Posted January 16, 2018 Share Posted January 16, 2018 The info you're looking for would be found by looking up the singleton class pattern. In this design a class is only constructed once by forcing the construction to be done by a static method of the class. You can prevent external code from constructing instances of your class by making your __construct method private. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.