2

マルチマップを宣言する方法に問題があるようです:

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

次のエラーメッセージが表示され続け、これを解決する方法に非常に行き詰まっています!

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

C++ で multimap を試すのはこれが初めてです。これが些細な問題のように思われたら申し訳ありません。誰かが私を正しい方向に向けてもらえますか?

私のcentral.hには次のコードがあります

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

public:
  Central(int _address);

central.cpp:

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

using namespace std;

#include "central.h"

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

お時間をいただきありがとうございます!:)

4

1 に答える 1

5

あなたは#includedしていません<map>。そのため、コンパイラは multimap を型ではなく変数と見なします。

于 2012-11-11T20:26:06.927 に答える