HELP! templates and hashmaps again

This is a discussion on HELP! templates and hashmaps again within the C++ Programming forums, part of the General Programming Boards category; ok, i fixed all the .h file errors, but now i have some NASTY .cpp errors here is the constructor, ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    43

    Exclamation HELP! templates and hashmaps again

    ok, i fixed all the .h file errors, but now i have some NASTY .cpp errors

    here is the constructor, at the moment its the only thing that is not commented out
    a version of my .h file which still has errors will be attached for referance, but like i said, its the old version before i fixed it so its really screwy. i think the problem has to do with my definitions syntax, not really sure...its driving me nuts, anyway...PLEASE HELP!!! IM DYING HERE! DEADLINE IS APPROACHING

    template HashMap<class KeyType, class ValueType>
    HashMap<KeyType, ValueType>::HashMap(hashfunc h, int buckets)
    {
    if (buckets <= 0)
    {
    string s1 = "HashMap Constructor";
    throw HashMapException(s1);
    }

    element **buckets;
    buckets = new *element[numbuckets];
    for ( int i = 0; i <= numbuckets; i++ )
    {
    buckets[i] = NULL;
    }

    hashfunc = h;
    }

    these are my errors

    In file included from HashMap.h:55,
    from HashMap.cpp:1:
    HashMap.cpp:15: return type specification for constructor invalid
    HashMap.cpp:15: parse error before `{'
    HashMap.cpp:22: syntax error before `*'
    HashMap.cpp:23: ANSI C++ forbids declaration `buckets' with no type
    HashMap.cpp:23: parse error before `*'
    HashMap.cpp:24: syntax error before `<='
    HashMap.cpp:24: syntax error before `++'
    HashMap.cpp:29: ANSI C++ forbids declaration `hashfunc' with no type
    HashMap.cpp:29: `h' was not declared in this scope
    HashMap.cpp:30: parse error before `}'
    HashMap.cpp:15: return type specification for constructor invalid
    HashMap.cpp:15: duplicate explicit instantiation of `HashMap<KeyType,ValueType>::HashMap(int (*)(KeyType), int)'
    HashMap.cpp:15: parse error before `{'
    HashMap.cpp:22: syntax error before `*'
    HashMap.cpp:23: ANSI C++ forbids declaration `buckets' with no type
    HashMap.cpp:23: redefinition of `int buckets'
    HashMap.cpp:23: `int buckets' previously defined here
    HashMap.cpp:23: parse error before `*'
    HashMap.cpp:24: syntax error before `<='
    HashMap.cpp:24: syntax error before `++'
    HashMap.cpp:29: ANSI C++ forbids declaration `hashfunc' with no type
    HashMap.cpp:29: redefinition of `int hashfunc'
    HashMap.cpp:29: `int hashfunc' previously defined here
    HashMap.cpp:29: `h' was not declared in this scope
    HashMap.cpp:30: parse error before `}'
    HashMap.cpp: In instantiation of `HashMap<KeyType,ValueType>::HashMap(int (*)(KeyType), int)':
    HashMap.cpp:15: instantiated from here
    HashMap.cpp:15: explicit instantiation of `HashMap<KeyType,ValueType>::HashMap(int (*)(KeyType), int)' but no definition available
    HashMap.cpp: In instantiation of `HashMap<KeyType,ValueType>::HashMap(int (*)(KeyType), int)':
    HashMap.cpp:15: instantiated from here
    HashMap.cpp:15: explicit instantiation of `HashMap<KeyType,ValueType>::HashMap(int (*)(KeyType), int)' but no definition available
    HashMap.cpp: In instantiation of `HashMap<KeyType,ValueType>::HashMap(int (*)(KeyType), int)':
    HashMap.cpp:15: instantiated from here
    HashMap.cpp:15: explicit instantiation of `HashMap<KeyType,ValueType>::HashMap(int (*)(KeyType), int)' but no definition available
    make: *** [HashMap.o] Error 1
    Attached Files Attached Files

Popular pages Recent additions subscribe to a feed

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