mentoring S.data

#include <iostream.h>#include <conio.h>

//implementasi class Antrian
class Antrian{
private : int data[10]; int *rear; int *front; int i;
public : Antrian(); void enqueue(int in); void dequeue(); bool IsFull(); bool IsEmpty();};

// implementasi enqueue
Antrian :: Antrian(){ i = 0; front = &data[0]; rear = &data[0];
for(int i = 0; i<10; i++) {  data[i] = 0; } }
void Antrian ::enqueue (int in){ if(IsFull() == false){  i++;  *rear = in;  rear = &data[i]; }else{  cout << “Antrian Penuh”; }}

//implementasi dequeue
void Antrian ::dequeue (){ if(IsEmpty() == false){
cout << *front << endl;
for(int indx = 0; indx<i; indx++)  {   data[indx] = data[indx+1];  }
i–;  *rear = 0;  rear = &data[i];   }else{  cout << “Antrian kosong” << endl; }}
bool Antrian ::IsEmpty (){ if(rear == front){  return true; }else{  return false; }}
bool Antrian ::IsFull (){ if(rear == &data[10]){ // Asumsikan antrian max 10  return true; }else{  return false; }}

//Contoh penggunaan :
int main(){
Antrian x;
x.enqueue (20);  //[1] x.enqueue (39);  //[2] x.enqueue (35);  //[3] x.enqueue (85);  //[4] x.enqueue (98);  //[5] x.enqueue (80);  //[6] x.enqueue (78);  //[7] x.enqueue (87);  //[8] x.enqueue (77);  //[9] x.enqueue (10);  //[10]
x.dequeue ();  //[1] x.dequeue ();  //[2]    x.dequeue ();  //[3] x.dequeue ();  //[4] x.dequeue ();  //[5] x.dequeue ();  //[6] x.dequeue ();  //[7] x.dequeue ();  //[8] x.dequeue ();  //[9] x.dequeue ();  //[10]
}

semoga bisa untuk belajar xan semua…!!