I'm getting an error message on each of the getters for a class i'm writting.
The error says:
error: passing `const model::container::Item' as `this' argument of `void model::container::Item::get_fields()' discards qualifiers
I'm assuming the problem is that my get_fields() method has the potential to modifiy division_, but I have division declared as mutable so I would think everything should be fine. What am I missing?
get_fields() is not const if it can change a member. Therefore division isn't either and you should not declare it as such. The mutable keyword subverts the entire const system.
Either way it should still compile the way i'm doing it.
I'm doing this because I don't want do a look up on the database every time a new object is constructed. I want to wait until I know I need the data before doing the full read. At that point all the fields are set once and for all.