if (in.is_open()) {
in >> numOfObj;
for (int i = 0; i < numOfObj; i++) {
getline(in, var1);
in >> var2;
in >> var3;
in.ignore();
this->addAlarm(var1, var2, var3);
}
in.close();
}
}
None of the data is saved from my file to my variables.
There's a lot that needs to be assumed here. But if the rest of the code is ok, here's a question: how do the values get transferred from var1, var2, var3 to fileModell, filePrice, fileMonth?
very open-ended, what is it that you don't understand and what have your tried towards understanding? Did you look up each of the unfamiliars? Be more specific and don't expect to be spoon-fed
As far as I can tell, the main problems are
(a) missing ignore() after in >> numOfObj;
(b) no checking of file status after attempting to read from it.
Here's a complete example. Note, I had to use my imagination to guess what the rest of the code might be like.
"Be more specific and don't expect to be spoon-fed " - you're right of course. I got a bit carried away, I wanted to test the code before suggesting the required fixes to be made.
But really, the onus is on the OP to post some code which can be compiled and run.