/* Copyright © 2007 Ankur Banerjee. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License version 2.1 as published by the Free Software Foundation. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. http://www.fsf.org/licensing/licenses/lgpl.html /
/ Constructors – Person Data /
#include <iostream.h>
#include <conio.h>
#include <stdio.h>
#include <string.h>
int flag = 0;
class address
{
char name[20], street[15], city[20], state[15];
int houseno;
public:
address()
{
houseno = 0;
strcpy(name, ”);
strcpy(street, ”);
strcpy(city, ”);
strcpy(state, ”);
}
address(int num, char n[20], char st[15])
{
houseno = num;
strcpy(name, n);
strcpy(street, st);
strcpy(city, “Delhi”);
strcpy(state, “India”);
}
void disp(char n[20])
{
if (strcmp(n, name) == 0)
{
cout<<endl<<“Name : “<<name<<endl
<<“House number : “<<houseno<<endl
<<“Street : “<<street<<endl
<<“City : “<<city<<endl
<<“State : “<<state<<endl;
flag = 1;
}
}
} ;
void main()
{
clrscr();
int h;
char n[20], st[15];
cout<<endl<<“Enter house number : “;
cin>>h;
cout<<“Enter name : “;
gets(n);
cout<<“Enter street : “;
gets(st);
address ad (h, n, st);
cout<<“Enter the same name again : “;
gets(n);
ad.disp(n);
if (flag == 0)
cout<<endl<<“Moron, I said enter the SAME name!”<<endl;
getch();
}
/ Output */
Enter house number : 42
Enter name : Arthur Dent
Enter street : 42, Guide Road
Enter the same name again : Arthur Dent
Name : Arthur Dent
House number : 42
Street : 42, Guide Road
City : Delhi
State : India