PPP2 Chapter 21 Drill 1

Code: https://gist.github.com/DragonOsman/55fdfe564195be3661992391c859ef40

In the debugger, I see that it correctly reads the Items and puts them into the vector. But that when it then goes back to check the loop condition after filling the vector, it triggers an exception that gets caught by my catch (...) block. The trouble is that I don't know what the exception is. There's also only one item in my call stack the whole time (the current line in main that's being executed). There's also one called "External Code" but it never actually goes in there and shows me what's in it.

When I do "Run Without Debugging", this is the output I get:
items.txt
Unknown exception occurred
Please enter a character to exit
x
Press any key to continue . . .


Would someone please help me out? Thanks in advance.

P.S. This is what the Drill asks for:
1. Define a struct Item { string name; int iid; double value; /* . . . */ }; , make
a vector<Item> , vi , and fill it with ten items from a file.
2. Sort vi by name.
3. Sort vi by iid .
4. Sort vi by value; print it in order of decreasing value (i.e., largest value
first).
5. Insert Item("horse shoe",99,12.34) and Item("Canon S400", 9988,499.95) .
6. Remove (erase) two Item s identified by name from vi .
7. Remove (erase) two Item s identified by iid from vi .
8. Repeat the exercise with a list<Item> rather than a vector<Item>.


I'm on number 1.
Last edited on
Both stoi(...) and stod(...) may throw. Note that they throw if the string is empty.
Topic archived. No new replies allowed.