-
March 18th, 2009, 05:26 AM
#1
Baffling Problem
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.]
Last edited by Zwischenzug; March 18th, 2009 at 05:41 AM.
-
March 18th, 2009, 05:40 AM
#2
Re: Baffling Problem
Put the function declaration directly in the template class instead...
Nobody cares how it works as long as it works
-
March 18th, 2009, 10:08 PM
#3
Re: Baffling Problem
The get template needs to be terminated with a semicolon.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|