My teacher got me a code to study and I can't figure out when I typedef
the map (as i commented in the code) it works fine but when I define without typedef
it doesn't seems to work. If someone could be kind to explain I would be grateful! I read something about "cyclic dependency" but not sure if it's the case here.
int main (){
map <string, string> ri; // typedef map<string, string> maps;
//maps ri;
ri.insert(pair<string, string>{"Smoljan", "Dragan"});
ri.insert(pair<string, string>{"Smolver", "Tina"});
ri.insert(pair<string, string>{"Mirkovic", "Sonja"});
string in;
cout<<"Input:";
cin>>in;
string high(in);
high.back()++;
auto low = ri.lower_bound(in);
/*(maps)*/ ri::key_compare comp; //<----- here is the error
//....
}
Best Answer
Well, cause is clear: ri is not a class, namespace or enumeration. It is an object.
What you need is to place before semicolons what you put with typedef: type name.
or (C++11)