class CyberWorm
{
private:
const std::string cyber_worm_os_;
const std::string cyber_worm_name_;
const int cyber_worm_dormancy_time_;
CyberWorm(); // Prevent the use of an empty constructor
// Add your variables here
public:
CyberWorm(std::string cyber_worm_os, std::string cyber_worm_name, int cyber_worm_dormancy_time);
CyberWorm(const CyberWorm& other); //copy constructor;
int getDormant();
const std::string getWormName();
const std::string getWormOs();
I tried to change the copy constructor to an not initiallion list format but it did'nt help.
Also- in an other cpp file on the same src file I wrote an empty constructor and it does compile.
> error: passing ‘const CyberWorm’ as ‘this’ argument of (...) discards qualifiers
look for const-correctness
Because a constant variable cannot change its state you cannot call methods on it that may change its state.
If you've got a member function that does not change the state of the object you need to inform the compiler, then you can use constant objects with it. const std::string getWormOs() const;