error C4430

Hello,

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.

Here is my class 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
//DPAProgram002
//definition and implementation file for MyQueue class

#ifndef MYQUEUE_H
#define MYQUEUE_H

#include <iostream>
using namespace 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
Your functions need return types.

1
2
3
4
// bad
template<typename T>
MyQueue<T>::isEmpty()
{
1
2
3
4
// good
template<typename T>
bool MyQueue<T>::isEmpty()
{


You're doing that for all your functions, it looks like.
Oh wow Thank You!! I was hoping it was something simple. Sometimes I get so focused I miss the simple things.
Topic archived. No new replies allowed.