UPDATE: I reviewed some place, and now the problem has somehow changed.
I am writing a C ++ class. How:
class qqq{
map<int,int> core;
int& operator[](int n){return core[n];};
};
int main(){
qqq a;
a[3]=7;a[5]=0;
int b=a[3];
return 0;
}
Although case A and case B call the same function (overloaded operator), case a is used as an lvalue, and case b is used as an rvalue.
For some reason, I want to have the effect that if 0 is passed in [5], remove node 5 in the kernel. How:
int& operator[](int n){
if(CASE A && THE VALUE PASSED TO IT IS 0)
core.erase(core.find(n));
else
return core[n];
}
Perhaps my description is inaccurate.
source
share