I'm getting an error saying:
error: passing `const model::container::Item' as `this' argument of `void model::container::Item::get_fields()' discards qualifiers

I'm getting the message for each of the getters in my class which are declared like this

const int& division()const{
    get_fields();
    return division_;
}

I'm assuming I'm getting this error because my get_fields() method has the potential to modify division_, but I have division defined as mutable so I would think it should be fine. What am I missing?

Recommended Answers

All 2 Replies

> What am I missing?

Making get_fields() a const member function.

Please post a short, complete example that illustrates the problem.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.