the aim of this program is to create a record of 20 members inputted by the user st the phone number is stored in 3 different parts e.g. 011-234-7891 where 011 is area code 234 is exchange and 7891 is numbr...every record must have a member id and member name and number in this format........ and the phone number should be in a different class called phone containing area code,exchange and number as variables
also we have to provide an option to the user for searching the records by member name or phone number.. I was able to do the searching by member name ... but for searching by member phone number i am getting an error.... the first member is shown every time searching is done by phone number .. please tell me wher i have gone wrong...
p.s. i know this is a very simple program but i just cannot find where i have done the mistake.. im giving the name of the classes used and only expanded the member functions which are required for checking the records by phone number
#include<iostream>
#include<iomanip>
#include<cstring>
using namespace std;
class phone
{
public:
int area_code,exchange,numbr;
void get_number();
};
class member
{
int member_id;
char membername[50];
phone number;
public:
void get_memberinfo();
void show_memberinfo();
int check_membername(char *n);
int check_num(int &,int &,int &);
};
member record[20];
char *n;
void phone :: get_number()
{
}
void member :: get_memberinfo()
{
}
void member :: show_memberinfo()
{
}
int member :: check_membername(char *n)
{
}
int member :: check_num(int &a,int &b,int &c)
{
if (number.area_code==a && number.exchange==b &&number.numbr==c)
return 0;
else
return 1;
}
void searchby_name()
{
}
void searchby_numbr()
{
int num1,num2,num3,i,flag=1,loc;
char c;
cout<<"Enter phone number in the format \'areacode - exchange - number (003 - 2442 - 6523)\' "<<endl;
cin>>num1>>c>>num2>>c>>num3;
for(i=0;i<3;i++)
{
if (record[i].check_num(num1,num2,num3)==0);
{
flag=0;
loc=i;
break;
}
}
if (flag==0)
{
cout<<"Member found"<<endl;
cout<<"Member id"<<setw(25)<<"Member Name"<<setw(25)<<"Phone number"<<endl;
record[loc].show_memberinfo();
flag=1;
}
else
cout<<"Member not found"<<endl;
i=0;loc=0;
cin.clear();
}
int main()
{
CODE for entering and printing the members
if(choice==1)
searchby_name();
return 0;
}