Subj : E2303 To : borland.public.cpp.borlandcpp From : Michal Augustyniak Date : Sun Dec 19 2004 05:52 am I'm getting an E2303 error which is a typename expected when compiling this headed I get it on line 20 where I use an Object reference return type. Mind you I get the same error when the reference to the return type is removed and I try compile it with a straight Object return. Can someone tell me how to get rid of this problem? template class ArrayStack { private: // member data enum { CAPACITY = 1000 }; // default capacity of stack int capacity; // actual length of stack array Object* S; // the stack array int t; // index of the top of the stack public: // constructor given max capacity ArrayStack(int cap = CAPACITY) { capacity = cap; S = new Object[capacity]; t = -1; } int size() const // number of elements in the stack { return (t + 1); } bool isEmpty() const // is the stack empty? { return (t < 0); } Object& top() throw(StackEmptyException) { if (isEmpty()) throw StackEmptyException("Access to empty stack"); return S[t]; } // push object onto the stack void push(const Object& elem) throw(StackFullException) { if (size() == capacity) throw StackFullException("Stack overflow"); S[++t] = elem; } // pop the stack Object pop() throw(StackEmptyException) { if (isEmpty()) throw StackEmptyException("Access to empty stack"); return S[t--]; } // ... // pop the stack Object pop() throw(StackEmptyException) { if (isEmpty()) throw StackEmptyException("Access to empty stack"); return S[t--]; } // ... (continuation of ArrayStack) ArrayStack(const ArrayStack& st); // copy constructor // assignment operator constructor ArrayStack& operator=(const ArrayStack& st); ~ArrayStack() // destructor { delete [] S; } }; /*template // copy constructor ArrayStack:: ArrayStack(const ArrayStack& st) { capacity = st.capacity; t = st.t; S = new Object[capacity]; for (int i = 0; i <= t; i++) { // copy contents S[i] = st.S[i]; } }*/ template // assignment operator ArrayStack& ArrayStack:: operator=(const ArrayStack& st) { if (this != &st) { // avoid self copy (x = x) delete [] S; // delete old contents capacity = st.capacity; t = st.t; S = new Object[capacity]; for (int i = 0; i <= t; i++) { // copy contents S[i] = st.S[i]; } } return *this; } .