Loading a txt file back into a vector

I have a problem with what to do on the load part. The code works fine as follows:

Add employee
Delete employee
save file
exit

I have added another option, which is to load the saved file back into the vector. I have tried to write the code, but it goes straight to "Database could not be loaded", and I am stuck. I have only posted the code relevant to load. Name, salary and ID are all in the base class Employee, and Manager, Engineer & Researcher are all derived from that using polymorphism. I can write the load code, to print out the saved file, but cannot write it back into the vector, which is what I am trying to do. So here are the code snippets, the main is the full main.cpp. I want to be able to load the file based on the ID number, which is 1 = manager, 2 = engineer & 3 = researcher. I will only post the code relevant to a manager, as the rest are the same.

All I would like is some help to load a txt file back into the program. I have 3 Managers, 3 Engineers & 3 Researchers stored on the file, with 3 common attributes and a couple of non common attributes.The save file option works fine, and I can read the file to console, just need to be able to write the information back into the vector

Try adding some debug code, like printing the value of Database.size() just before the loop, add some messages within the load() function so that it's displaying what it's doing etc. The load might be working perfectly.

IDnum is initialised to zero and never changed, so maybe that's why IDnum==1, IDnum==2 and IDnum==3 always evaluate to FALSE.

Do you intend for the line "Database->load(infile);" to be the only line included within the for loop?

In general I think debugging your code would be a *lot* easier if you indented it correctly.

1.Employee counter is saved when you save the file, the idea being it will tell the for loop how many times to execute.

2. ID num, tells the system if if is a manager, engineer or researcher.

3. I have created a new manager, engineer and researcher to store the downloaded data in a vector Employee*.

3. The load->infile part, will load in the class employee objects, and non common objects only applicable to the class, be it manager, engineer or researcher as I have set this in the load method in employee.cpp

That's the problem. You're ignoring what IS happening, and substituting in your brain what you WANT to happen for what IS happening. So you fall into the classic trap: you think there aren't any bugs, so you decide there aren't any bugs. But there are, because it doesn't work as you expect. This is a contradiction, so you decide to yell for help. In reality what's going on here is that there are some bugs in your code so you have to stop thinking that there aren't and start thinking that there are. Then you have to find them.

>> Employee counter is saved when you save the file, the idea being it will tell the for loop how many times to execute.

Yes, but it won't do that automatically. What is the value of Database.size() before the loop? Or did you prefer to ignore my advice in favour of posting the above drivel?