Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
35 views

Term Paper: Name Inder Pal Singh Class Roll - No. Submitted To

The document describes a term paper assignment to: 1) Create a base class to represent employees with attributes like ID, name, salary, etc. 2) Derive classes like project leader and manager from the base class. 3) Implement functions for insertion, deletion, and searching of employees. 4) The program uses hybrid inheritance with one base class and multiple derived classes to represent different employee types. Functions allow input, output, and searching of employee records.

Uploaded by

Inderpal Singh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Term Paper: Name Inder Pal Singh Class Roll - No. Submitted To

The document describes a term paper assignment to: 1) Create a base class to represent employees with attributes like ID, name, salary, etc. 2) Derive classes like project leader and manager from the base class. 3) Implement functions for insertion, deletion, and searching of employees. 4) The program uses hybrid inheritance with one base class and multiple derived classes to represent different employee types. Functions allow input, output, and searching of employee records.

Uploaded by

Inderpal Singh
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 16

TERM PAPER

write a class to represent employee


in a company. Taking this a base
class write
derived classes like project-
leader,manager
etc,
implement insertion, deletion and
search. Employee has details like id,
name, salary, designation,address

Name  Inder Pal Singh


Class  J1801

Roll.no.  B28

Submitted To  Respected Anshu Mam


Inheritance
Inheritance allows one data type to acquire
properties of other data types. Inheritance from a
base class may be declared as public, protected, or
private. This access specifier determines whether
unrelated and derived classes can access the
inherited public and protected members of the base
class. Only public inheritance corresponds to what is
usually meant by "inheritance". The other two forms
are much less frequently used. If the access
specifier is omitted, a "class" inherits privately, while
a "struct" inherits publicly. Base classes may be
declared as virtual; this is called virtual inheritance.
Virtual inheritance ensures that only one instance of
a base class exists in the inheritance graph
Type of Inheritance used in this program is Hybrid
Inheritance.

In hybrid in heritance there is on base class and


more than two base classes the pictorial
representation of hybrid inheritance is: -

Base Class

DERIVED DERIVED DERIVED


CLASS 1 CLASS 2 CLASS 3
#include<conio.h>

#include<iostream.h>

class emp

public:

int id,sly;

char name[20],desi[20],adr[30];

void ip()

cout<<"\tENTER ID\n\t";

cin<<id;

cout<<"\n\tENTER NAME\n\t";

cin>>name;

cout<<"\n\tENTER SALARY\n\t";

cin>>sly;
cout<<"\n\tENTER DESIGNATION\n\t";

cin>>desi;

cout<<"\n\tENTER ADDRESS\n\t";

cin>>adr;

};

class pr_leader:public emp

void disp()

cout<<"\n\tID="<<id<<"\n\tNAME="<<name<<"\n\tSA
LARY="<<sly<<"\n\tDESIGNATION="<<desi<<"\n\tA
DDRESS="<<adr;

};
class manager:public emp

void disp()

cout<<"\n\tID="<<id<<"\n\tNAME="<<name<<"\n\tSA
LARY="<<sly<<"\n\tDESIGNATION="<<desi<<"\n\tA
DDRESS="<<adr;

};

class worker:public emp

void disp()

{
cout<<"\n\tID="<<id<<"\n\tNAME="<<name<<"\n\tSA
LARY="<<sly<<"\n\tDESIGNATION="<<desi<<"\n\tA
DDRESS="<<adr;

};

void main()

int a,n,m,i,s,t,u,g;

clrscr();

emp h[50];

pr_leader o[50];

manager p[50];

worker q[50];

do

{
cout<<"\n\tPress\n1 for insert\n2 for delete\n3 for
search";

cin>>m;

switch(m)

case1:

cout<<"HOW MANY INSERTIONS DO YOU WANT


TO MAKE";

cin>>n;

cout<<"\n\tpress \n1 for PROJECT LEADER\n2 for


MANAGER\n3 for WORKER";

cin>>s;

if(s==1)

for(i=0;i<n;i++)
{

o[i].ip();

cout<<"new values inserted are";

for(i=0;i<n;i++)

o[i].disp();

else if(s==2)

for(i=0;i<n;i++)

p[i].ip();

cout<<"new values inserted are";


for(i=0;i<n;i++)

p[i].disp();

else if(s==3)

for(i=0;i<n;i++)

q[i].ip();

cout<<"new values inserted are";

for(i=0;i<n;i++)

q[i].disp();

}
break;

case 2:

cout<<"deleation of employees will start from last


inserted to previous like a stack\nAnd according to
their placement";

cout<<"How many employes you want to delete";

cin<<t;

cout<<"\n\tPress\n1 for Project leader\n2 for


manager\n3 for worker";

cin>>u;

if(u==1)

if(t>n)

cout<<"wrong input"
}

else

n=n-t;

cout<<"values after deletion are";

for(i=0;i<n;i++)

o[i].disp();

else if(u==2)

if(t>n)

{
cout<<"wrong input"

else

n=n-t;

cout<<"values after deletion are";

for(i=0;i<n;i++)

p[i].disp();

else if(u==3)

if(t>n)
{

cout<<"wrong input"

else

n=n-t;

cout<<"values after deletion are";

for(i=0;i<n;i++)

q[i].disp();

else(u>3||u<1)

{
cout<<"wrong input";

break;

case3:

cout<<”enter id to see its info”;

cin>>g;

for(i=0;i<n;i++)

If(h.id==g)

o[i].disp();

Else

Cout<<”ID does not exists”;


break;

default:

cout<<"WRONG INPUT";

cout<<"to continue press 1";

cin>>a;

}while(a==1)

getch();

You might also like