
May 3rd, 2005, 10:08 AM
|
|
Registered User
|
|
Join Date: May 2005
Posts: 2
Time spent in forums: 1 h 52 m 48 sec
Reputation Power: 0
|
|
|
C++ PhoneBook
Hi!
I have to write a main program in which i read from a file phonebook.txt into a dynamic array of Phinebook objects and asign data to each. Using a loop display each object data. Prompt the user to select a number on the array to modify a Phinebook entry. When the user has chosen a valid entry, asks the user if he wants to alter the entire entry or just the phone number. Accepts new data values accordingly. If the user wants to modify the entire entry, create a temporary object to correct location in the array. If the user wants to change the area code and phone number, or change the phone number only, prompt the values, then use the [] or () operator to asign the new values to the proper existing object within the array. After update has taken effect, redisplay the Phonebook entries. If the user exists the program the array info must be save in the file.
This is what i have so far...
Code:
#include <fstream.h> // libraries
class Phonebook{
private: char FirstName [12];
char LastName [12];
char AreaCode [4];
char PhoneNumber[8];
public: Phonebook();
void operator [] (const Phonebook &PhoneNumber);
void operator () (const Phonebook &AreaCode, &PhoneNumber);
void operator = (const Phonebook &FirstName, const Phonebook &LastName, const Phonebook &AreaCode, const Phonebook &PhoneNumber);
void print()const;
};
void main()
{
fstream book;
book.open("phonebook.txt", ios::in);
if (!book)
cout << "ERROR! opening phonebook.txt" << endl;
book >> FirstName >> LastName >> AreaCode >> PhoneNumber;
Phonebook *array=NULL, objeto;
array = new Phonebook[5]; for (int i=0; i<= 5; i++)}
|