Guaranteeing only one instantiation of a class
The question I'm working on is: Create a class that represents a printer connection, and that only allows you to have one printer.
Can someone give me a clue as to how to implement a class that limits the number of instantiations? I thought of having a class member which I can set to "false" if the static counter is already at 1, but this means the failed object nonetheless exists and seems messy since the client has to test the state of the object on their end. Better to have the object abort its own construction if there is already one in existence. But how do I go about doing this? Clue needed!