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. Quote Link to comment Share on other sites More sharing options...
Solution kicken Posted January 16, 2018 Solution 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.