10

Interviewer: Could you please make a class to force it create one instance at most?
Me: Sure!
(I didn't know the singleton pattern)

class A {
public static bool isCreated = false;
A() {
if(isCreated == true)
throw new Exception();
isCreated = true;
}
}

Comments
Add Comment