简体   繁体   English

ISO C ++禁止声明无类型的“ multimap”

[英]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. 这是我第一次在C ++中尝试多图,如果这是一个小问题,我感到抱歉。 Could someone please point me in the right direction? 有人能指出我正确的方向吗?

In my central.h I have the following code 在我的central.h中,我有以下代码

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

public:
  Central(int _address);

In central.cpp: 在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> . 您尚未#include d <map> That's why the compiler thinks that multimap is a variable rather than a type. 这就是为什么编译器认为multimap是变量而不是类型的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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