Hi. I have an unusual problem here. The code seems fine but VC++ is giving me the following errors:
error C2143: syntax error : missing ';' before '*'
error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
error C2065: 'T' : undeclared identifier
The line of code that gives the error is:
template <typename T> class LinkedList
{
class ListNode;
class Lookuptable;
};
template <typename T> class LinkedList::LookupTable
{
public:
ListNode* get( int );
private:
ListNode* *nodeTable;
};
template <typename T> ListNode* LinkedList<T>::LookupTable::get( int pos ) //errors on this line
{
return nodeTable[ pos ];
}
[P.S. All unneccessary code removed. When the function template get( int pos ) is removed (leaving the forward function declaration in the LookupTable inner class), code compiles fine.]
[P.S.S. LookupTable is simply an array of ListNode pointers.]


Reply With Quote

Bookmarks