Reputation: 5301
I am viewing a source code and it has got a singleton class like :
class A {
private:
A() {}
~A() {}
};
And i see no copy constructor and assignment operator. When i talked about it, i got the response that it would not fail.
But i had read that making copy constructor and assignment operator private or inaccessible is important. But i am unable to generate some breaking test cases.
What test case can create two objects of this class ?
Upvotes: 0
Views: 127
Reputation: 258568
Assuming you can get a hold of an instance of A
, you could copy it with
A* a = new A(instance);
An automatic variable wouldn't work because of the private destructor.
Upvotes: 3