void IPManager::createUn(const std::string& file)
{
std::ofstream f;
f.open(file);
for (IP element : list)
{
std::cout << element; //****** Getting an error here
}
f.close();
}
//(..)
IPManager::IPManager()
{
}
//This method will read IP, MAC address, interface etc from a .txt file.
//Then save the content to a vector defined as std::vector<IP> list
void IPManager::load(const std::string &file)
{
std::ifstream f;
f.open(file);
std::string output;
f >> output;
std::cout << output;
std::string tmp_intf;
std::string tmp_ip;
int tmp_mask;
std::string tmp_mac;
int tmp_rec;
int tmp_sent;
std::stringstream readf(output);
readf >> tmp_intf >> tmp_ip >> tmp_mask >> tmp_mac >> tmp_rec >> tmp_sent;
IP myread;
myread.setIP(tmp_ip);
myread.setInterfaceName(tmp_intf);
myread.setMask(tmp_mask);
myread.setMACAddress(tmp_mac);
myread.setTrafficRec(tmp_rec);
myread.setTrafficSent(tmp_sent);
//Add the IP address, interface, mac information etc to a vector
list.push_back(myread); //<===== Save to vector here
f.close();
}
I don't know what an "IP" is. Is your class? Is it someone else's class? Evidently there's no operator<<() overload, so if you want line 8 to work you'll have to define one, I guess.