C++ Help

Associate
Joined
25 Jul 2003
Posts
1,980
A noob C++ question for you. This is a very simple C++ program (well it doesn't actually do anything!). When I try and compile I get the error:

test.hh:14 error: ISO C++ forbids declaration of `map' with no type"

Can anyone explain to me why I cant put a map as a member variable in the header? If I write that line within a method body in the .cc file it works fine, but I need it as a member variable.


test.hh
Code:
#include <map>
#include <string>

namespace TestMap
{

  class MapTester {
  public:
    MapTester();
    void TestMap();
  private:
    map<int,int> test;
  };

}

test.cc
Code:
#include "test.hh"
using namespace TestMap;
using namespace std;

MapTester::MapTester()
{
}

void MapTester::TestMap()
{
}

int main()
{
}
 
Back
Top Bottom