MENU
Question -

Write the definition of a member function INSERT() for a class QUEUE in C+ +, to remove a product from a dynamically allocated Queue of items considering the following code is already written as a part of the program-

Struct ITEM 
{
int INO; char INAME[20];
ITEM*Link;
};
class QUEUE 
{
ITEM *R,*F;
Public:
QUEUE(){R=NULL; F=NULL;}
void INSERT();
void DELETE();
~QUEUE();
};



Answer -

Void QUEUE::INSER()
{
ITEM*newitem = new ITEM; 
Cout<<"enter item number";
cin>>newitem → INO;
Cout<<"Enter item name";  
gets(newitem → INAME); 
newitem → Link = NULL; 
if (R==NULL)
R=F=newitem;
else
{
 R → Link=newitem; 
 R = newitem;
}

Comment(S)

Show all Coment

Leave a Comment

Free - Previous Years Question Papers
Any questions? Ask us!
×