Click on circlist.cpp to get source.
// File Circlist/circlist.cpp
#include <iostream>
#include "circlist.h"
using namespace std;
int circlist::pop(void) {// remove front cell, return its info
if( empty() ) return 0; // if empty, return 0
// by-pass front cell
cell *front = rear->next; rear->next = front->next;
int x = front->info; delete front;
return x; // return value of front
}
circlist::~circlist(void){// destructor
cell *curr = rear->next; cell *oldc;
do {oldc = curr; curr = curr->next;
delete oldc;}
while(oldc != rear);
cout << "Deleted a circlist" << endl;
}
ostream& operator<<(ostream& os, circlist& L) {
cell* curr = L.rear->next;
os << "Circlist: ";
while(curr != L.rear)
{os << curr->info << " "; curr = curr->next;}
os << "[" << curr->info << "]" << endl;
return os;
}