Hi there,
You will need to create a class, conveniently called phonebook.
This class will contain an array of integers, strings, or phonenumber-structs (depending on how you want to format or search the data and complex you want to get).
The member functions of this class, add(), delete(), search(), view() and edit(), will all act upon that array as needed.
I.e. the add function will add an element to the array, the delete() function will delete an element, etc.
Personally I would start out with following rudimentary declarations (i think anyway, from the top of my head):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
|
struct PhoneNumber
{
std::string number;
std::string name;
};
class PhoneBook
{
Phonenumber listing[MAX_PN];
unsigned int count;
public:
void add(PhoneNumber pn);
void delete(int index);
void edit(int index);
void search(std::string search_string);
};
//definitions here
int main ()
{
PhoneNumber p1 = { "123456", "some name"};
PhoneNumber p2 = { "123789", "some other name"};
PhoneBook book;
book.add(p1);
book.add(p2);
book.search("123456");
return 0;
}
|
That's quite improvised, but i think it would do the job nicely.
As said, you can also use strings or ints rather than structs, but I feel a struct is tidiest here.
Hope that gets you on your way.
All the best,
NwN