Share with others

Friend Function Implementation using C++
#include
#include #include
#include
#include
int i=0;
int idno;
class student
{
public:
friend void issue ();
friend void  ret ();
};
class lib
{
char name[10];
int roll; 

public:

int status;
lib();
void idinfor();
friend void issue ();
friend void  ret ();
};
lib::lib()
{
status=0;
}
void lib::idinfor()
{
i++;
cout<<“\n\n\t\t ENTER UR NAME…”;
gets(name);
cout<<“\n\n\t\t ENTER UR ROLL NO…”;
cin>>roll;
cout<<“\n\n\t\t UR ID NUMBER IS….”<<i+1998;< p=””>

}
void issue(int status)
{

int bn;
cout<<“\n\n\t\t LIST OF AVAILABLE BOOKS FOR U”;
cout<<“\n\n\t\t PRESS 1 BALA\n\t\t PRESS 2 VENU\n\t\t PRESS 3 OOPS\n\t\t PRESS 4 MAT”;
cout<<“\n\n\t\t ENTER UR CHOICE”;
cin>>bn;

if(status<3)
    {
cout<<“\n\n\t\t BOOK IS AVAILABLE FOR U”;
}
else
{
cout<<“\n\n\t\t BOOK IS NOT AVAILABLE FOR U”;
cout<<“\n\n\t\t U CANT ISSUE MORE THAN TWO BOOKS”;
}
}
void ret()
{
cout<<“\n\n\t\t THANK YOU”;
}
void main()
{
lib l[10];
int ch;
clrscr();
do
{
cout<<“\n\t\t PRESS 1 FOR UR ID NUMBER INFORMATION”;
cout<<“\n\t\t PRESS 2 FOR ISSUE A NEW BOOK “;
cout<<“\n\t\t PREES 3 FOR RETURN A BOOK “;
cout<<“\n\t\t PRESS 4 FOR EXIT”;
cout<<“\n\t\t ENTER UR CHOICE…”;
cin>>ch;
switch(ch)
{
case 1:
clrscr();
l[i].idinfor();
break;
case 2:
clrscr();
cout<<“\n\n\t\tENTER UR ID NO…”;
cin>>idno;
issue(l[i].status);
l[i].status++;
break;
case 3:
clrscr();
cout<<“\n\n\t\tENTER UR ID NO…”;
cin>>idno;
ret();
l[i].status–;
break;
case 4:
exit(0);
break;
}
}while(ch!=4);
}


Share with others