Object oriented program in C++ to create a database of the personnel information system

, by Prashant Gunjal

Develop an object oriented program in C++ to create a database of the personnel information system containing the following information: Name,Date of Birth,Blood group,Height,Weight,Insurance Policy number,Contact address,telephone number,driving license no. etc Construct the database with suitable member functions for initializing and destroying the data viz constructor,default constructor,copy constructor,destructor,static member functions,friend class,this pointer,inline code and dynamic memory allocation operators-new and delete.


CPP program :


#include<iostream.h>
#include<conio.h>
#include<string.h>

class info
{
private:
char *name,*date,*add,*bg;
float ht,wt;
long int incno,telno,licno,len;
public:
info();
info(char*name1);
void create();
void display();
inline void disp()
{
cout<<"\nEnter Record.........";
}
friend void show()
{
cout<<"\nName\t\tAddress \tBirth  Bloog group";
cout<<"  Height   Weight  LICno INC";
}
};
info::info()
{
static int cnt=0;
cout<<"\nStatic Count is ="<<cnt;
cnt++;
cout<<"\nCount="<<cnt;
cout<<"\nDefault constructor.......";
this->ht=0;
this->licno=0;
this->name='\0';
this->date='\0';
this->add='\0';
this->bg='\0';
this->len=0;
}
info::info(char * name1)
{
len=strlen(name1);
name=new char[len+1];
strcpy(name,name1);
cout<<"Parametrized const......";
}
void info::create()
{
char name1[20];
int len;
if(name=='\0')
{
cout<<"\nEnter name=> ";
cin>>name1;
len=strlen(name1);
name=new char[len+1];
strcpy(name,name1);
}
cout<<"\nEnter Date of Birth => ";
cin>>name1;
len=strlen(name1);
date=new char[len+1];
strcpy(date,name1);
cout<<"\nEnter address => ";
cin>>name1;
len=strlen(name1);
add=new char[len+1];
strcpy(add,name1);
cout<<"\nEnter teliphone no=> ";
cin>>telno;
cout<<"\nEnter Blood Group => ";
cin>>name1;
len=strlen(name1);
bg=new char[len+1];
strcpy(bg,name1);
cout<<"\nEnter Height => ";
cin>>ht;
cout<<"\nEnter Weight => ";
cin>>wt;
cout<<"\nEnter Liscence no => ";
cin>>licno;
cout<<"\nEnter Incumtax  no => ";
cin>>incno;

}
void info::display()
{
     cout<<"\n"<<name<<"\t"<<add<<"\t"<<date<<"  "<<bg;
     cout<<"\t\t"<<ht<<"\t"<<wt<<"\t"<<licno<<"\t"<<incno;


}
void main()
{
clrscr();
info obj1,obj,a,b,c;
obj1.disp();
obj1.create();
info obj2("Rameshwar");
obj2.disp();
obj2.create();
show();
obj1.display();
obj2.display();
getch();
}

OUTPUT :




Static Count is =1
Default constructor.......
Static Count is =2
Default constructor.......
Static Count is =3
Default constructor.......
Static Count is =4
Default constructor.......
Static Count is =5
Default constructor.......
Enter Record.........
Enter name=> prashant

Enter Date of Birth => 2/12/1992

Enter address => khandgoan

Enter teliphone no=> 123456

Enter Blood Group => b+ve

Enter Height => 5.6

Enter Weight => 57

Enter Liscence no => 123

Enter Incumtax  no => 345
Parametrized const......
Enter Record.........
Enter Date of Birth => 2/10/1991

Enter address => karvenagar

Enter teliphone no=> 123457

Enter Blood Group => o+ve

Enter Height => 5.5

Enter Weight => 56

Enter Liscence no => 345

Enter Incumtax  no => 7890

Name            Address         Birth  Blood group  Height   Weight  LICno  INC
prashant        khandgoan       2/12/1992  b+ve         5.6     57      123       345
Rameshwar       karvenagar      2/10/1991  o+ve         5.5     56      345   7890


0 comments: