I am getting the below sonarqube static code analysis error:
Explicitly define the missing copy constructor, move constructor, copy assignment operator and move assignment operator so that they will not be implicitly provided.
I am getting the above message at the below Destructor declaration in the header file:
~CCPSDataManager();
And also in my .cpp file, there is definition for this Destructor ~CCPSDataManager().
Here do I need to follow the rule of 5 by providing the Destructor, copy constructor and the copy-assignment operator, move constructor and the move-assignment operator? Or is there any other approach?
And also If I define the copy constructor, copy-assignment operator, move constructor and the move-assignment operator we are writing many lines of code without using those. Is this a correct approach?
Please suggest and give me some insight on how to proceed?
Here do I need to follow the rule of 5 by providing the Destructor, copy constructor and the copy-assignment operator, move constructor and the move-assignment operator?
Depends on what you do in the destructor.
In most cases, if you need a destructor, then you need to follow rule of 5 because in most cases the implicitly generated ones do the wrong thing. Not always, but in most cases. The analyser that you use suggests to follow the rule of 5 because of the assumption that it may be necessary.
Or is there any other approach?
If there is no need for the custom destructor, then follow the rule of 0 instead: Don't define a custom destructor.
And also If I define the copy constructor, copy-assignment operator, move constructor and the move-assignment operator we are writing many lines of code without using those.
If you don't use them, then simplest solution is to define them deleted.