简体   繁体   中英

ISO C++ forbids declaration of ‘multimap’ with no type

There seems to be a problem in the way that I am declaring my multimap:

std::multimap<int, std::string> table;

I keep getting the following error message and am quite stuck on how to solve this!

error: ISO C++ forbids declaration of ‘multimap’ with no type
error: invalid use of ‘::’
error: expected ‘;’ before ‘<’ token

This is my first time trying multimap in C++, and I'm sorry if this seems a trivial problem. Could someone please point me in the right direction?

In my central.h I have the following code

class Central{
  private:
  int address;
  std::multimap<int, std::string> table;

public:
  Central(int _address);

In central.cpp:

#include <iostream>
#include <string>
#include <sstream>
#include <map>

using namespace std;

#include "central.h"

Central::Central(int _address)
{
    address = _address;         
}

Thank you for your time! :)

You haven't #include d <map> . That's why the compiler thinks that multimap is a variable rather than a type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM