The code above doesn't enforce the use of mutable. It is the code that you didn't post that requires it. Somewhere in your code you have a method declared as const or accepting the TargetTracking instance as a const object and some code is trying to change this const (through inheritance from the class) member which is forbidden. Therefore rather than using "mutable", you should pay attention to your const methods and const objects. Use mutable only as a means of last resort or when you know what you are doing (e.g. when implementing a cache that needs to be built from within a const method). And of course this is plain C++, nothing Qt specific.
Bookmarks