Hello, I am working on a practice customer database program. Everything is ok just Im dumbfounded on how to do the search function I have no clue where to start. I want the user to beable to type in the order Number and the customers info would come up.
Using an std::ifstream you could imput these values into the map and provide lookup functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// defined at the top of your file
map<int, customerData*> _customers;
bool search(int order) {
map<int, customerData*>::iterator c;
c = _customers.find(order);
return (c != _customers.end()) ? true : false;
}
// elsewhere
customerData *c;
if (search(0001))
c = _customers[0001];
cout << c->orderNumber; // => 0001
cout << c->fullName; // => "Aragorn"
cout << c->email; // => "aragorn@gondor.net"
This is a contrived example of a simple mapping application. A real database like SQL does a lot more than accessing names by id. I'm sure this is just a practice project like you said, but you wouldn't want to do the above as a real life answer to this issue.