I'm having a problem getting this to work..
I got 3 files,
start.C - Where i got my main() function
Menu.C & Menu.h - Where I'm trying to use hash_map
start.C
#include <iostream>
#include "Menu.h"
using namespace std;
int main() { /* test code here */ return 0; }
Menu.h
#ifndef _MENU_H_
#define _MENU_H_
class Menu {
public:
Menu() { }
~Menu() { }
private:
hash_map< const char*, int, hash<const char*>, eqstr > hashmap;
};
#endif
Menu.C
#include <iostream>
#include <string>
#include <hash_map>
struct eqstr {
bool operator()(int s1, int s2) {
return s1 == s2;
}
};
#include "Menu.h"
-----------------------------
The code doesn't actually do anything now but I just want to get this working before i continue my little project. I've tried using hash_map in a separate file and it worked.
Compiler errors for the code above:
[jp@Slacktop:~/devel/cpp/001/] g++ start.C Menu.C
In file included from start.C:2:
Menu.h:10: `hash' was not declared in this scope
Menu.h:10: parse error before `char'
Menu.h: In method `Menu::Menu()':
Menu.h:6: parse error before character 0240
Menu.h: In method `Menu::~Menu()':
Menu.h:7: parse error before character 0240
In file included from Menu.C:11:
Menu.h: In method `Menu::Menu()':
Menu.h:6: parse error before character 0240
Menu.h: In method `Menu::~Menu()':
Menu.h:7: parse error before character 0240
The second line "'hash' was not declared in this scope" is probably the root of this evil error but I'm clueless on how to fix this..
any suggestions?
guidelines and recommendations on how to use multiple files are also appreciated.
Slackware 8.0, Linux 2.4.5, G++ 2.95.3