What will be the output of the following C++ code? [code] #include <iostream> #include <map> using namespace std; int

Julipkq

New member
What will be the output of the following C++ code?
Code:
    #include <iostream>
    #include <map>
    using namespace std;
    int main ()
    {
        try {
            map<char, int> mymap;
            map<char, int> :: iterator it;
            mymap['a'] = 50;
            mymap['b'] = 100;
            mymap['c'] = 150;
            mymap['d'] = 200;
            it = mymap.find('b');
            mymap.erase (it);
            mymap.erase (mymap.find('d'));
            cout << mymap.find('a') -> second << '\n';
        }
        catch (...) 
        {
            cout << "Unknown exception: " << endl;
        }
        return 0;
    }
A. 50
B. 100
C. 150
D. Exception
 

Tìm kiếm

Back
Top