Template Warnings/Errors... C4346

This is a discussion on Template Warnings/Errors... C4346 within the C++ Programming forums, part of the General Programming Boards category; Hello folks, I've had this warning (that creeps up to an error) multiple times and I thought I finally had ...

  1. #1
    Registered User
    Join Date
    Jan 2006
    Location
    Seattle
    Posts
    30

    Template Warnings/Errors... C4346

    Hello folks,

    I've had this warning (that creeps up to an error) multiple times and I thought I finally had templates ingrained in my brain so that it would never come back to haunt me again, but unfortunately it has...

    Here's my class definition:

    Code:
    template <typename T>
    class OAHashTable
    {
      public:
          // Slots that will hold the key/data pairs
        struct OAHTSlot
        {
          char Key[MAX_KEYLEN]; // Key is a string
          T Data;               // Client data
          enum OAHTSlot_State {OCCUPIED, UNOCCUPIED, DELETED};
          OAHTSlot_State State;
        };
    
    
        OAHashTable(const OAHTConfig& Config);
        ~OAHashTable();
    
          // Insert a key/data pair into table. Throws an exception if the
          // insertion is unsuccessful.
        void insert(const char *Key, const T& Data) throw(OAHashTableException);
    
          // Delete an item by key. Throws an exception if the key doesn't exist.
          // Adjusts the table by moving key/data pairs, if necessary
        void remove(const char *Key) throw(OAHashTableException);
    
          // Find and return data. Throws an exception if the key doesn't exist. 
        T& find(const char *Key) const throw(OAHashTableException);
    
          // Removes all items from the table (Doesn't deallocate table)
        void clear(void);
    
        OAHTStats GetStats(void) const;
        const OAHTSlot *GetTable(void) const;
    
      private:
        // Private fields and methods
    };
    And here's the class function I'm having trouble with.

    Code:
    template <typename T>
    const OAHashTable<T>::OAHTSlot* OAHashTable<T>::GetTable(void) const
    {
    }
    There's something wrong with the the way I'm defining the function in my .cpp because Visual Studios 2005 tells me that

    Code:
    Warning	1	warning C4346: 'OAHashTable<T>::OAHTSlot' : dependent name is not a type
    Error	2	error C2143: syntax error : missing ';' before '*'
    Error	3	error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    I believe the errors are a trickle down effect from the warning but I can't figure out what I'm doing wrong. I know it has to do with the way I'm defining the * to the struct that I'm returning but through all my mixing and matching of trying to get the definition correct I've not yet stumbled upon the correct form.

    I looked through a couple template websites, searched for the C4346 warning, and now I find myself here. I hope someone can lead me in the right direction.

    Thanks in advance,
    -Peter

  2. #2
    Registered User
    Join Date
    Jan 2006
    Location
    Seattle
    Posts
    30
    Two seconds later I remember what I'm doing wrong...

    Code:
    template <typename T>
    const typename OAHashTable<T>::OAHTSlot* OAHashTable<T>::GetTable(void) const
    {
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Specialising a member function with a template template parameter
    By the4thamigo_uk in forum C++ Programming
    Replies: 10
    Last Post: 10-12-2007, 04:37 AM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. error: template with C linkage
    By michaels-r in forum C++ Programming
    Replies: 3
    Last Post: 05-17-2006, 08:11 AM
  4. Class Template Trouble
    By pliang in forum C++ Programming
    Replies: 4
    Last Post: 04-21-2005, 04:15 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21