//PhoneBook00.cpp
#include <iostream.h>
int const MAX_LEN = 10;
const char *testNames[] =
{"Bob", "Tom", "Ann", "Ron", "Ben", "Ken", "Rob",
"Sam", "Don", "Dan", "Tim"};
const int MAX_NAMES = sizeof(testNames)/sizeof(testNames[0]);
const char *testPhones[] =
{"111-1111", "222-2222", "333-3333", "444-4444"};
const int MAX_PHONES = sizeof(testPhones)/sizeof(testPhones[0]);
const char *testGroups[] =
{"111-1111", "222-2222", "333-3333", "444-4444"};
const int MAX_GROUPS = sizeof(testGroups)/sizeof(testGroups[0]);
struct CPhoneEntry
{
char name[MAX_LEN+1];
char phone[14+1];
char group[10+1];
int key;
CPhoneEntry *next;
};
class CPhoneBook
{
private:
CPhoneEntry *first;
CPhoneEntry *last;
int count;
public:
CPhoneBook(void);
CPhoneBook(char ch);
~CPhoneBook(void);
CPhoneEntry * searchByName(char name[]);
void sortByName(void);
bool insert(CPhoneEntry entry);
bool insert(char name[], char phone[], char group[], int key);
bool modifyPhone(char name[], char newPhone[]);
};
CPhoneBook::CPhoneBook(void)
{
count = 0;
first = NULL;
last = NULL;
}
void main(void)
{
cout << "MAX_NAMES = " << MAX_NAMES << endl;
cout << "sizeof(testNames) = " << sizeof(testNames) << endl;
cout << "sizeof(testNames[0]) = " << sizeof(testNames[0]) << endl;
}
|