Hello!

    I declared a simple class:

       class Table {
        public:

           static Table* getInstance( char *key );

       }

    The getInstance method look in a map and returns a instance of a Table class.

    I've a map that stores all the references of "Tables" class:

    typedef std::map< char *, Table *  > map_tables ;
    static map_tables tables;


    And finally the getInstance method:

    Table* Table::getInstance( char *key ) {

        // If the table has previous be instanciated...
       if ( tables.count( key ) ) {
              // Get the previous reference
              Table *t = tables[ key ];
       }
    }

    When I try to compile, I get a error from CodeWarrior:

    Error   : pointer/array required
 (point of instantiation: 'Table::getInstance(char *, char *)')
  (instantiating: 'std::map<char *, Table *, std::less<char *>, std::allocator<std::pair<char *const , Table *>>>::operator[](char *const &)')
   (instantiating: 'std::__tree<std::pair<char *const , Table *>, std::map<char *, Table *, std::less<char *>, std::allocator<std::pair<char *const , Table *>>>::value_compare, std::allocator<std::pair<char *const , Table *>>>::find_or_insert<char *, Table *>(char *const &)')
tree line 1252      return insert_node_at(p, leftchild, is_leftmost, value_type(key, V() )->data_;
Project: Nanos.mcp, Target: Debug, Source File: Table.cpp


    The code that causes error is "tree" from MSL library, at line:

        if (prev == 0 || comp()(prev->data_, key))
            return insert_node_at(p, leftchild, is_leftmost, value_type(key, V() )->data_;
        return prev->data_;

    What is wrong?

many thanks!!

Régis



--
For information on using the PalmSource Developer Forums, or to unsubscribe, please see http://www.palmos.com/dev/support/forums/

Reply via email to