having trouble with the print and the main
#include <fstream>
#include <iostream>
using namespace std;
struct Item
{
int value;
Item *next;
};
class Queue
{
protected:
Item *fill;
Item * remove;
public:
void addingtoqueue(int);
int takeaway(void);
bool empty (void);
Queue (void);
};
class Merge: public Queue
{
protected:
Item *merge(Item*,Item*);
Item *mergesort(Item*);
Item *divide(Item*);
public:
void print(void);
Item* merge_sort(Item*);
};
Queue::Queue()
{
fill = NULL;
remove = NULL;
}
void Queue::addingtoqueue(int x)
{
Item *p;
p = new(Item);
p -> value = x;
if( remove == NULL)
{
remove = p;
p-> next = NULL;
fill = p;
}
else
{
fill -> next = p;
p-> next = NULL;
fill = p;
}
}
bool Queue:: empty()
{
if( fill == NULL)
return true;
else
{
return false;
}
}
Item *
Merge::divide (Item *a)
{
Item * b, *c;
b = a;
c = a -> next;
c = c -> next;
while( c != NULL)
{
c = c-> next;
b = b -> next;
if ( c!= NULL)
c = c -> next;
}
c = b -> next;
b -> next = NULL;
return c;
}
Item* Merge:: mergesort(Item *p)
{
Item *q;
if(p!= NULL)
{
if( p->next !=NULL)
q = divide(p);
p = mergesort(p);
p = merge(p,q);
}
return p;
}
Item* Merge:: merge( Item *p, Item *q)
{
Item *r ,* start;
if( p-> value < q -> value)
{
r = p;
p = p -> next;
start = r;
}
else
{
r = q;
q = q -> next;
start = r;
}
while( p != NULL && q != NULL)
{
if( p -> value < q -> value)
{
r -> next = p;
r = p;
p = p -> next;
}
else
{
r -> next = q;
r = q;
q = q -> next;
}
}
if( p == NULL)
{
r ->next = q;
}
else
r -> next = p;
return start;
}
void Merge::print()
{
}
int main()
{
int value,x;
Merge Y;
cout<< " Please enter a value " << endl;
while( x != '0')
{
cin>>x;
Y.addingtoqueue(x);
cout<< " You entered" << x << endl;
}
cout<< " the values sorted "<< Y.merge(x,value) << endl;
cout<< " the list of of the values sorted " << Y.mergesort(value)<<endl;
system("pause");
return 0;
}