0

I can figure it out why my compiler response like this when i try to access ->first and ->second fields of iterator. I used before a map structure but not with a string as key.

ERROR: error C2675: unary '++' : 'std::string' does not define this operator or a conversion to a type acceptable to the predefined operator

#include <iostream>
#include <map>
#include <string>
using namespace std;

void display(map <string, string> v){
    map <string, string> ::iterator it = v.begin();
    map <string, string> ::iterator end = v.end();
    for (; it != end; ++it){
        cout << "Name:" << it->first << "---->";
        cout << "Adress:" << it->second << endl;
    }
}
int main()
{
    map <string, string > v;
    string name;
    string adress;

    do
    {
        cout << "Name:";
        cin >> name;  // getline(cin, name);
        cout << "\nAdress:";
        cin >> adress; // getline(cin, adress);
        v.insert(name, adress);

    } while (name == "exit");

    display(v);
} 

Can you tell me guys what am I writing wrong?

Hemoto
  • 1
  • 1

0 Answers0