In my code myclass has two two const functions which are being called by some other const functions. In this class I am not modifying anything except bool variable.
In this code bool variable "isCreated" is being used to check if something is created or not. If not created then create it in function fooUpdate().
myclass.h
class myclass
{
public:
myclass()
{}
~myclass() {}
void fooUpdate() const;
void fooCreate(bool arg) const;
bool isCreated; //should I make it mutable or static
};
myclass.cpp:
void myclass::fooCreate(bool arg) const //In this function I am not modifying anything except bool variable.
{
isCreated = arg;
//create
}
void myclass::fooUpdate() const
{
if(!isCreated)
{
//create
}
else
{
//update
}
}
some other classes
//These functions will always be const. Not in my scope to change it.
create() const {
lClass.fooCreate(true);
}
update() const {
lClass.fooUpdate();
}
Now I have two options either make isCreated mutable or static. I just want to know which is better option ?