// A simple "caller ID" program #include #include #include using namespace std; // add a number, name pair to the phonebook void add(vector &phonebook, int number, string const& name) { phonebook[number] = name; } // given a phone number, determine who is calling void identify(const vector & phonebook, int number) { if (phonebook[number] == "UNASSIGNED") cout << "unknown caller!" << endl; else cout << phonebook[number] << " is calling!" << endl; } int main() { // create the phonebook; initially all numbers are unassigned vector phonebook(10000, "UNASSIGNED"); // add several names to the phonebook add(phonebook, 1111, "fred"); add(phonebook, 2222, "sally"); add(phonebook, 3333, "george"); // test the phonebook identify(phonebook, 2222); identify(phonebook, 4444); }