Baffling Problem
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Baffling Problem

  1. #1
    Join Date
    Mar 2009
    Posts
    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.

  2. #2
    Join Date
    Jun 2002
    Location
    Stockholm, Sweden
    Posts
    1,600

    Re: Baffling Problem

    Put the function declaration directly in the template class instead...
    Nobody cares how it works as long as it works

  3. #3
    Join Date
    Jan 2009
    Posts
    35

    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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center