0

I have a class like this :

class XYZ {
public :
  bool var1 = true;
  ABC *var2 = nullptr;

public :
  XYZ() = default;

  void SetVar1(bool flag)
  {   var1 = flag;  }

  void SetVar2(ABC *abc)
  {   var2 = abc;  }
}

I want to know that if my objects for XYZ are referenced as const everywhere in my codebase, can I use these setters? P.S. I have tried with const Setters and it doesn't work (I knew it doesn't make much sense but I was stuck in the compilation error so tried it anyway)

StoryTeller - Unslander Monica
  • 165,132
  • 21
  • 377
  • 458

1 Answers1

1

Once u make ur object const u can't change value of any varables in this object

Ibrahim.Sluma
  • 164
  • 13