Trouble with template coding

I am practicing by implementing dequeue using array instead of deque STL.
But I faced some errors... Please help me solve this
Thank you very much

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
template<typename elem>
class DequeArray {
private:
	int CAPACITY;
	int _size;
	int _front, _back;
	elem *arr;
public:
	DequeArray();
	~DequeArray();
	int size();
	bool empty();
	bool push_front(const elem& e);
	bool push_back(const elem& e);
	bool pop_front();
	bool pop_back();
	const elem& front;
	const elem& back;

};


and

1
2
3
4
template<typename elem>
const elem& DequeArray<elem>::front() {
	return arr[_front];
}


The error is shown at the second code. It is shown that "Error 2 error C2350: 'DequeArray<elem>::front' is not a static member c:\___________\dequearray.h 88
"
and
"Error 1 error C2063: 'DequeArray<elem>::front' : not a function c:\___________+\dequearray.h 88
"


They are both in the same header file.
It is easier to implement function in the class itself. But I would like to know how to implement outside the class.

Thank you very much :))

**Moreover, this is quite unrelated but I would like to know that...
is there any recommended books for programming contest?
closed account (zb0S216C)
In your class, DequeArray::front is a reference to a constant elem object, not a function.

Edit: Don't mention it.

Wazzak
Last edited on
Topic archived. No new replies allowed.