I'm working on a school project of boolean minimization, and here I want to delete some elements of a set of my user defined class. This is where the error occurs:
(dc and PI are both sets of my class Term
, passed to this function by reference. std::set<Term>& dc, PI
)
for (const auto& n : dc) {
for (const auto& i : n.getMinterm()) {
m[i] = 0;
for (auto &x : PI) {
x.delMinterm(i);
}
}
}
The error message is:
- Error (active) E1086 the object has type qualifiers that are not compatible with the member function "Term::delMinterm"
- Error C2662 'void Term::delMinterm(int)': cannot convert 'this' pointer from 'const Term' to 'Term &'
This is the content of my class:
class Term {
private:
int group = 0;
int literal = 0;
std::string term;
std::set<int>minterm;
bool isDontCare;
bool merged;
};
Function delMintern(int)
just erases the selected element from the set minterm
.
Though I didn't use "const auto&" but "auto&", it still shown as a const object.
I've tried taking off the '&' but it just create a local duplicate, however, I want to directly modify the original one.
I also tried something like:
for (auto x : PI) {
PI.erase(x);
x.delMinterm(i);
PI.insert(x);
}
but it caused a "read access violation" error.