When I want to disallow class copy in C++, I usually declare a private operator= and a copy constructor and I don't implement them:
class MyClass
{
char* _str;
int _len;
MyClass(const MyClass& rhs); //No implementation
MyClass& operator=(const MyClass& rhs); //No implementation
public:
MyClass();
MyClass(const char *);
}
Is this considered a bad style? Is there another way to do this?