// sorry .... continue .... --> this is not part of the code
--------------------------
void person::print()
{
cout << " ----------------------- " << endl ;
cout << first_name << " " << second_name << endl ;
cout << "Age = " << age << endl ;
cout << "Phone # = " << phone_number << endl;
}
bool person::set_name(char fn[],char sn[])
{
first_name[0]='\0';
second_name[0]='\0';
if (strlen (fn)<=9)
{
strcpy(first_name,fn);
}
else
return false;
}
void person::get_full_name(char
{
into_here[0] = '\0';
strcat(into_here,first_nam
strcat(into_here," ");
strcat(into_here,second_na
}
void person::get_phone_number(c
{
into_here[0] = '\0';
strcat(into_here,phone_num
}
bool person::set_phone_number(c
{
phone_number[0] = '\0';
if (strlen (from_here)<=19)
strcpy (phone_number, from_here);
else
return false;
}
void main()
{
person Buddy ;
Buddy.input() ;
Buddy.print() ;
}
Main Topics
Browse All Topics





by: meow00Posted on 2003-12-12 at 16:28:50ID: 9932117
#include <iostream>
# include <string>
class person
{
private:
int age;
char first_name[10];
char second_name[10];
char phone_number[20];
public:
void set_age(int a);
int get_age();
void print();
void input();
bool set_name (char fn[], char sn[]);
void get_full_name (char into_here[]);
void get_phone_number (char into_here[]);
bool set_phone_number (char from_here[]);
};
void person::input()
{
string temp ;
cout<<"age?"<<endl;
cin>>age;
int flag1=1;
while(flag1 == 1){
cout <<"first name ?"<<endl;
cin >> temp ;
if (strlen(strdup(temp.c_str(
{ cout << " OOOps .... first name too long " << endl; continue ;}
strcpy(first_name,temp.c_s
flag1 = 0 ;
}
int flag2=1;
while(flag2== 1){
cout <<"second name ?"<<endl;
cin >> temp ;
if (strlen(strdup(temp.c_str(
{ cout << " OOOps .... second name too long " << endl; continue ;}
strcpy(second_name,temp.c_
flag2 = 0 ;
}
cout <<"phone # ??? " << endl ;
cin >> phone_number ;
}
void person::set_age(int a)
{
age = a;
}
int person::get_age()
{
return age;
}