a simple c++ program for an adress book that adds contact, stores the contacts and searches for the contact... it should have only one class called class addy_book..i called a constructor and am stuck coz i don't know where to go from here

#include <iostream>
#include <fstream>

using namespace std;

class addy_book {
   private:
     char*fname;
     char*lname;
     double fone_num;
     char sex;
public: 
     addy_book();
     add_to();
     view();
     search();
     };

Is that all of the instructions you were given? I'm sort of surprised that your instructor didn't explain in greater detail what each of those methods were supposed to do.

i am supposed to build on it besides and determine what each method is suppised to do.... the addy_book is the constuctor function, add_to,...which adds new contact or update a contact, view shows what you have stored in the address book, and search helps you search through a particular database

this is what i have so far

#include <iostream>
#include <string>
using namespace std;

class addy_book {

      private:
              char fname[20];
              char lname[20];
              char sex ;
              double fone_num;
     public:
            addy_book();
            int menu();
            int option;
            char* add_contacts();
            char* view_contacts();
            char* search_contacts();
            char* address_users[10];  
            int i;
};
int addy_book::menu() {

         cout<<"\t\t -------------------- MENU ------------------"<<endl;
         cout<<"\n\t\t\t\t1. add to contacts "<<endl;
         cout<<"\n\t\t\t\t2. view contacts in address book"<<endl;
         cout<<"\n\t\t\t\t3. search through the contacts in address book"<<endl;
         cout<<"\n\n\nENTER OPTION : "<<endl;
         cin>> option;


         if(option == 1) {

                   addy_book a;
                   a.add_contacts();

         }else if(option == 2) { 

               addy_book a;
               a.view_contacts();

         }else if(option == 3) {

               addy_book a;
               a.search_contacts();
         }

} 

addy_book::addy_book() {

     cout <<"enter your first name \n" ;
     cin >> fname;

     cout <<"enter your last name \n" ;
     cin >> lname;

     cout <<" choose your sex (m or f) \n" ;
     cin >> sex;

     cout <<"enter your phone number\n" ;
     cin >> fone_num;
}



char* addy_book::add_contacts() {

      cout<<"\t\t -------------------- Add Contacts ------------------"<<endl;
      cout << "enter the contcats in this format: \n" ;
           for ( i = 0; i < 10; i++)
            {
                 cin >> address_users[i];
            }

            cout<<"PRESS '1' TO GO BACK TO THE MAIN MENU"<<endl;
            cin >> option;

 } 

char* addy_book::view_contacts() {  

            cout<<"\t\t -------------------- view contacts ------------------"<<endl; 
            cout << "these are the contacts in the address book\n" ;
             for ( i = 0; i < 10; i++)
            {
                 cin >> address_users[i];
            }

            cout<<"PRESS '1' TO GO BACK TO THE MAIN MENU"<<endl;
            cin >> option;

} 

char* addy_book::search_contacts() {  

      char* target;
      int result;
      char ans; 

             cout<<"\t\t -------------------- search through contacts ------------------"<<endl; 
             cout << "search for a specific contact here \n";

             do 
             {
                  cout <<" enter a name to search for: ";
                  cin >> target;

                  result = search(address_users, target);
                     if( result == -1) {
                         cout <<target<< " is not on the list of contacts. \n" ;

                     }else{
                           cout <<target<< " is on the list and here are the details\n: \n" <<result<<endl
                           }

                       cout << "search again? (choose 'y'or 'n'): ";
                       cin ans;

             } while ((ans != 'n') && (ans != 'N'));

      }



 main () {

     cout << "welcome to zeus address system \n" ;

        int z;
        addy_book b;


        if(z != 0){
             b.menu(z);
              }else{
               cout<<"\n\nProgram Exiting . . .\n";      
         }


system("PAUSE");
return 0;
}

and i am confused at the moment can you tell me what is wrong or what i should do

1) Turn the computer off.
2) Sit at a desk with pen and paper
3) Write down the functions you need to create (add, delete, search, ...)
4) Take each one at a time and write the steps needed to accomplish them -- in great detail
5) Run through the steps a line at a time adding, deleting, etc. untill you know what you wrote works well.
6) Turn on the computer
7) Translate what you have into code.

This is the best, fastest, easiest way to program. 80% at a desk, 20% at the computer.

Think of anything that is to be created -- building, car, whatever. How much time do you imagine is used designing the thing vs. actually making it? The same with programs. More planning and design than typing code.

Edited 4 Years Ago by WaltP

This question has already been answered. Start a new discussion instead.