class NotCopyable
{
public:
NotCopyable() { }
private:
NotCopyable(const NotCopyable&);
NotCopyable& operator = (const NotCopyable&);
};
class BasicTimer : private NotCopyable
{
public:
...
}
Is this right to use private inheritance?
Yes, that is a perfectly acceptable – and even common – use of private member visibility. That will keep you from copying a
NotCopyable, or anything that derives from it, around.