I created a struct called employee and when I compile, I get an error telling me this:employees.cpp:44:25: error: no matching function for call to 'getline(std::ifstream&, employee&)'............What's up? I thought it looked good, but I'm pretty new so obviously it isnt.
You didn't declare 's'. add string s at the beginning of your function.
Edit: I think I see what you're trying to do, and why you're getting the error.
You're trying to read in a line of text with employee information and parse it into your employee struct. I assume you have a struct called employee somewhere.
in your innermost while loop you have a variable called s which your compiler assumes employee struct. But you've never declared it as such. You've just tried to set members of s. It looks like you're using s to refer to a string when you call getline(), but you also use it to refer to an employee struct in your innermost while loop.
You should declare a separate employee variable in your innermost while loop.
By the way, your code won't work properly as written, since you need to dynamically allocate your employee structs. Otherwise, they will get destroyed at the end of the while loop.
What can I use if I want to read in my struct? It has 3 attributes: string last, string first and double salary............I want to read the file 1 line at a time and used this method with strings before using getline..........is there an equivalent for structures?
Ya just figured it out.........................I have another problem....................how do I print out elements of a vector that i filled with a struct containing the same three attributes, using a pointer? I keep getting errors telling me that there is no operator << when I deference the pointer.
how do I print out elements of a vector that i filled with a struct containing the same three attributes, using a pointer? I keep getting errors telling me that there is no operator << when I deference the pointer.
We should not guess what you do. You should show what you do.
There is no overload of getline() or operator<< for struct employee, but you can change that by defining such overloads. You will then get a simpler main().