I am writing this dynamic queue class for an asignment and ran into the error code C4430. I researched this online and examined my code line by line for a variable missing a type but could not find one. I have made my queue as a template and am new to templates (got my dynamic stack template to work though) so maybe there is something I'm missing.
//DPAProgram002
//definition and implementation file for MyQueue class
#ifndef MYQUEUE_H
#define MYQUEUE_H
#include <iostream>
usingnamespace std;
template<typename T>
class MyQueue
{
private:
struct QueueNode
{
T value;
QueueNode *next;
};
QueueNode *front;
QueueNode *rear;
int numItems;
public:
MyQueue();
~MyQueue();
void append(T);
void serve(T &);
bool isEmpty();
bool isFull();
void clear();
};
//constructor
template<typename T>
MyQueue<T>::MyQueue()
{
front = NULL;
rear = NULL;
numItems = 0;
}
//destructor
template<typename T>
MyQueue<T>::~MyQueue()
{
clear();
}
//append function
template<typename T>
MyQueue<T>::append(T num)
{
QueueNode *newNode;
newNode = new QueueNode;
newNode->value = num;
newNode->next = NULL;
if (isEmpty())
{
front = newNode;
rear = newNode;
}
else
{
rear->next = newNode;
rear = newNode;
}
numItems++;
}
//serve function
template<typename T>
MyQueue<T>::serve(T &num)
{
QueueNode *temp;
if (isEmpty())
{
cout << "The queue is empty." << endl;
}
else
{
num = front->value;
temp = front->next;
delete front;
front = temp;
numItems--;
}
}
//isEmpty function
template<typename T>
MyQueue<T>::isEmpty()
{
bool status;
if (numItems)
status = false;
else
status = true;
return status;
}
//clear function
template<typename T>
MyQueue<T>::clear()
{
int value; //dummy variable for serve
while(!isEmpty())
{
serve(value);
}
}
#endif
and here are the error messages:
1>e:\school_uvu\2010\fall_2010\cs 2420\projects\dpaprogram002\dpaprogram002\myqueue.hpp(70) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\school_uvu\2010\fall_2010\cs 2420\projects\dpaprogram002\dpaprogram002\myqueue.hpp(90) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\school_uvu\2010\fall_2010\cs 2420\projects\dpaprogram002\dpaprogram002\myqueue.hpp(104) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>e:\school_uvu\2010\fall_2010\cs 2420\projects\dpaprogram002\dpaprogram002\myqueue.hpp(116) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int