dose not make sense ?
Dec 1, 2009 at 7:07pm UTC
hi for every body
this is code for queue using array during my work i found these errors that dosent make any sense
so the code file
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
// specifeaction file
const int MAXSZ=5;
class queue
{
public :
queue();
bool isfull()const ;
bool isempty()const ;
void Enqueue(int );
void Dqueue(int &);
private :
int data[MAXSZ];
int f;
int r;
};
// implemntaion file
# include<iostream>
# include"queue.h"
# include<string>
# include<cstdlib>
using namespace std;
queue::queue()
{
f=r=-1;
}
bool queue::isfull()const
{
return ((f==0&&r==MAXSZ-1)||r=f-1);
}
bool queue::isempty()const
{
return (f==-1&&r==-1);
}
void queue:: Enqueue(int n)
{
if (isfull())
cout<<" QUEUE IS FULL\n" ;
else
{ if (r==MAXSZ-1)
r=0;
else
r++;
//r=(r+1)%MAXSZ;
data[r]=n;
}
}
void Dqueue(int & n)
{
if (isempty())
cout<<" the QUEUE IS EMPTY\n" ;
else
{
if (f==r)
f=r-1;
else if ( f==MAXSZ-1)
f=0;
else f++;
}
//f=(f+1)%Mxsz;
}
// the clint file
# include<iostream>
# include"queue.h"
# include<string>
# include<stddef>
using namespace std;
int main()
{
queue q1;
q1.Enqueue(10);
q1.Enqueue(20);
q1.Enqueue(30);
q1.Enqueue(40);
q1.Enqueue(50);
cout<<" the queue : " <<q1.Enqueue(num)<<endl;
q1.Dqueue(num);
cout<<" the queue after deleting : " <<q1.Dqueue(num)<<endl;
q1.Enqueue(60);
cout<<" the queue : " <<q1.Enqueue(num)<<endl;
return 0;
}
the errors are
'f' : undeclared identifier
'r' : undeclared identifier
'=' : left operand must be l-value
fatal error C1083: Cannot open include file: 'stddef': No such
Dec 1, 2009 at 7:20pm UTC
You didn't put queue:: before Dqueue on line 67
You should also indent your code better
Dec 2, 2009 at 1:54pm UTC
thx for u
Topic archived. No new replies allowed.