21.write a programe for operator == for string
#include
#include
Class Prashant
{
char name[20];
int flag;
void getdata()
{
cout<<"Enter the Name";
cin>>name;
}
int operator==(prashant s)
{
flag=stremp(name,s.name);
return flag;
}
};
void main()
{
clrscr()
prashant s.t;
s.getdata();
t.getdata();
int x=(t==s);
y=(x==0)
cout<<"String are Equal";
else
cout<<"Not Equal";
getch();
}
22.Write a programe to demonstrate multiple hierasehical inheretense
a.accept deposit
b.display balance
c.compute & deposite interupt
4.permit withdrawl and update balance
#include
#include
Class account
{
public:
char name[25];
char type of[25];
int amt,bal,withdraw,deposit;
account()
{
bal=500;
}
void getdata()
{
cout<<"Enter the name,a/c number and the type of ";
cin>>name>>accno>>typeof;
}
};
class current:public account
{
public:
void getdeposit()
{
cout<<"Enter the Deposit amt\n";
cin>>deposit;
bal=bal+deposit;
}
void withdrawamt()
{
cout<<"Enter the amt to withdraw\n";
cin>>withdraw;
}
void penalty()
}
if(bal<500)
bal=bal-50;
}
void display()
{
cout<<"Name\t"<
}
};
class using:public account
{
float interest;
public;
void getdeposit()
{
cout<<"\nEnter the deposit amount\n";
cin>>deposit;
bal=bal+deposit;
}
void cal instrest()
{
int n=3;float r=7.5;
intrest=(bal*n*r)/100;
bal=bal+intrest;
}
void withdraw amt()
{
cout<<"Enter the amt to withdraw \n";
cin>>withdraw:
bal=bal-withdraw;
}
void penelty()
{
if(bal<500)
bal=bal-50;
}
void display()
{
cout<<"Name \t"<
}
};
void main()
{
clrscr();
current a;
a.getdata();
a.getdeposit();
a.withdrawamt();
a.penalty();
a.display();
savingb;
b.getdeposit();
b.calintrest();
b.withdrawamt();
b.penalty();
getch();
}
23.write a program to demonstrate hybride inheramtence
#include
#include
Class student
{
public:
char name[25];
int rollno;
void getdata()
{
cout<<"Enter the name & roll no of the student";
cin>>name>>rollno;
}
};
class test:public student
{
public:
int sem1,sem2;
void getmarks()
{
cout<<"\n Enter the marks of sem1 and sem2 \n";
cin>>sem1>>sem2;
}
};
class sports
{
public:
int sportmarks;
voidgetscore()
{
cout<<"\n Enter the marks of sports \n;
cin>>sportsmarks;
}
};
class result:public test.public sports
{
public:
int total;
void caltotal()
{
total=sem1+sem2+sportsmark;
}
void display()
{
cout<<"\n name1+"<
}
};
void main()
{
char();
resilts;
s.getdata();
s.getmarks();
s.getscore();
s.caltotal();
s.display();
getch();
}
24) WAP 2 model a database wth emp as a base class & wth the att name, id , for mgr att are titles & dues, writer attributes book labour att are wages.
#include
#include
class employee
{
public:
long id;
char name[25];
void get data()
{
cout<<"n\enter the name & id\n";
cin>>name>>id;
}
};
class manager:public employee
{
public :
char title[30];
long due;
void get info ()
{
cout<<"\n enter the title & dues amt\n";
cin>>title>>dues;
}
void display()
{
cout<<"\n Name\t"<
title \t"<
}
};
class writer:public employee
{
public:
char books [25];
void get books()
{
cout <<"\nenter the name of books\n";
cin>> books;
}
void display()
{
cout <<"\n Name \t"<
<
}
};
class labour :public employee
{
public:
int wages;
void get wages()
{
cout <<"enter the wages of the employee\n";
cin>>wages;
}
void display()
{
cout <<"enter the wages of the employee\n";
cin>>wages;
}
void display()
}
cout <<"\n Name \t"<
<
}
};
void main()
{
clrscr();
manager s;
s.getdata();
s.getinfo();
s.display();
writer a;
a.getdata();
a.getbooks();
a.getdisplay();
labour b;
b.getdata();
b.getwages();
b.display();
getch();
}