Possible Duplicate:
What's the most reliable way to prohibit a copy constructor in C++?
Suppose I want to make a class non-copyable and want to prohibit copy constructor and assignment operator. I make them private and leave unimplemented:
class Class {
//useful stuff, then
private:
Class( const Class& ); //not implemented anywhere
void operator=( const Class& ); //not implemented anywhere
};
this way if any of them is accidentially called from within friends or the same class I get a link-time error.
Now what if a user implements them? I mean there's no implementation, so anyone can add his own:
Class::Class( const Class& )
{
//whatever they want
}
Of course I could have created my own implementation and add an assertion there, but that would delay unintended calls detection until the program is run.
Is there a way to prevent implementing such method by a user and still have compile-time detection of unintended calls to them?