Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
a)employee name
employee code
designation
years of experience
age
b)Construct an object oriented data base to carry out the following methods:
ii)List a table
iv)Edit an entry
Ansclass employee
public:
int age,yoe,ec;
char desi[20],en[20];
void get()
cin>>en;
cin>>age;
cin>>desi;
cin>>yoe;
void disp()
};
int main()
{ employee E[100];
int n;
cin>>n;
for(int i=1;i<=n;i++)
{ E[i].get();
E[i].disp(); }
}
b) class B1
{ public:
char en[30],desi[30];
void get1();
void disp1();
};
class B2
{ public:
int age,yoe ;
void get2();
void disp2();
};
{ int ec;
public:
derived()
{
ec=0;
void get();
void disp();
};
void B1::get1()
cin>>en;
cin>>desi;
void B2::get2()
cin>>age;
cin>>yoe;
void derived::get()
B1::get1();
B2::get2();
void B1::disp1()
cout<<en<<"\t"<<desi<<"\t";
void B2::disp2()
cout<<"\t"<<age<<"\t"<<yoe;
void derived::disp()
B1::disp1();
B2::disp2();
cout<<"\t\t"<<ec<<"\n";
int main()
{derived obj[50],temp;
int i,j,no,ch;
char ans,key[30];
j=-1;
do
cin>>ch;
switch(ch)
case 1:
do
{j++;
obj[j].get();
cin>>ans;
}while(ans=='y'||ans=='Y');
break;
case2:
cout<<"-----------------------------\n";
for(i=0;i<=j;i++)
obj[i].disp();
break;
case 3:
cin>>no;
if(no<=j+1)
obj[j+1]=obj[no];
obj[no].get();
cout<<"Record inserted successfully";
j++;
else
cout<<"Error";
break;
case 4:
if(j!=-1)
cin>>no;
if(no<=j)
for(i=no;i<=j;i++)
temp=obj[i];
obj[i]=obj[i+1];
j--;
else
cout<<"\nerror";
else
case 5:
if(j!=1)
cin>>no;
if(no<=j)
obj[no].get();
else
else
{cout<<"Error....";}
break;
case 6:
cin>>key;
for(i=0;i<=j;i++)
if(strcmp(obj[i].en,key)==0)
{
obj[i].disp();
break;
break;
}while(ch<7);
Q.2 Develop an oops program in C++ to create a library information system containing the following for
all books in library.
Accession number
Year of publication
Publisher’s name
Cost of book
Construct the database with suitable member function for intialising and destroying the data.
Ans class book
public:
int an,yop,cb;
char na[20],tb[20],p[20];
void get()
{ int n;
cin>>n;
for(int i=1;i<=n;i++)
cin>>na;
cin>>tb;
cin>>p;
cin>>an;
cin>>yop;
cin>>cb;
}
void disp()
};
int main()
{ book *b;
b=new book;
b->get();
b->disp();
delete b;
}
Q.3 Explain the following with syntactic rule?
i)Public inheritence
ii)Protected inheritance
iii)private inheritance
*Each public member in the base class is public in the derived class.
* Each protected member in the base class is protected in the derived class.
* Each private member in the base class remains private in the derived class.
Private Inheritence
*Each public member in the base class is private in the derived class.
*Each protected member in the base class is private in the derived class.
*Each private member in the base class remains private in the base class and hence it is only visible in
the base class.
Protected Inheritence
*Each public member in the base class is protected in the derived class.
*Each protected member in the base class is protected in the derived class.
*Each private member in the base class remains private in the base class and hence visible only in the
base class.
Submitted by:-
Deepanshu Bansal
164024
G-2 group,2k16