Re: vector of (int,string). can't convert i->first to int
"Milan Krejci" <rdw@no-spam.mail.cz> wrote in message
news:f9ufvu$1uum$1@news.vol.cz...
int first=15,latest=15; QString typ=NULL;
std::map<int,std::string>::iterator i;
for(i = SeznamPracovniDoby.begin(); i != SeznamPracovniDoby.end();
i++)
{ if (typ==NULL) typ=i->second.c_str();
if (typ!=i->second.c_str()) { std::cout<<first<<"-"<<latest<<":"<<typ;
first=i->first; }
else { latest=i->first; typ=i->second.c_str(); }
std::cout << i->first << " " << i->second << std::endl;
}
I don't know what you are trying to show. Formatting your code and
replacing QString with std::string and changing it so it compiles, it
compiles.
#include <iostream>
#include <map>
#include <string>
int main()
{
std::map<int,std::string> SeznamPracovniDoby;
int first=15,latest=15;
std::string typ;
std::map<int,std::string>::iterator i;
for(i = SeznamPracovniDoby.begin(); i != SeznamPracovniDoby.end(); i++)
{
if ( typ == "" )
typ = i->second.c_str();
if (typ!=i->second.c_str())
{
std::cout<<first<<"-"<<latest<<":"<<typ;
first=i->first;
}
else
{
latest=i->first;
typ=i->second.c_str();
}
std::cout << i->first << " " << i->second << std::endl;
}
}
I don't know what you're trying to do though, and I don't know what QString
actually is. Post some compilable code that demonstrates the problem.