I have an abstract base class that has some virtual methods and a virtual destructor. I want to make the copy constructor and the assignment operator of the base class (and the derived class) as private so I can hide them and the static analysis tool (klockwork) cannot flag it. This is my code snippet:
class Parent: public mainParentClassIDontCareAbout
{
public:
Parent (int a);
virtual ~Parent ();
protected:
void doSomething();
.
.
private:
// Hide assignment operator and copy constructor
Parent (const Parent&) {};
Parent operator= (const Parent&) {return *this;};
} // end of parent class definition
class Child : public Parent
{
public:
Child (void *x, int y, bool z);
~Child ();
protected:
.
.
.
private:
// Hide assignment operator and copy constructor
Child (const Child&) {};
Child operator= (const Child&) {return *this;};
} // end of parent class definition
However, I get a compile time error as:
invalid abstract return type for member function ‘Lib::Parent Lib::Parent::operator=(const Lib::Parent&)’
I want to hide the assignment operator and copy constructor. Is this not a valid behavior when we have a virtual destructor or are there any solutions if I want to have the same scenario ?