0

I don't know what I did wrong that causes this error to appear.

This is the wrong code in the program:

if (set<int>::iterator itr = s.find(x)) {

And here is the whole program:

int main() {
    set<int>s;
    int q, y, x;
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> y;
        if (y == 1) {
            cin >> x;
            s.insert(x);
        }
        else if (y == 2) {
            cin >> x;
            if (set<int>::iterator itr = s.find(x)) {
                s.erase(x);
           }
            else {
            }
        }
        else {
            cin >> x;
            if (set<int>::iterator itr = s.find(x)) {
                cout << "Yes";
            }
            else {
                cout << "No";
            }
        }
    };
    return 0;
}

Does someone know how to fix this error?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Dung Tran
  • 11
  • 3

0 Answers0