通过' const *'作为'这个'如果比较则出错

时间:2015-07-24 21:24:41

标签: c++ c++11

我收到错误:

  

../ ConcreteRequest.h:23:49:错误:传递'const   std :: map,std :: basic_string>'as'this'   'std :: map< _Key,_Tp,_Compare,_ Alloc> :: mapped_type&的参数   std :: map< _Key,_Tp,_Compare,_ Alloc> :: operator [](std :: map< _Key,_Tp,   _Compare,_Alloc> :: key_type&&)[with _Key = std :: basic_string; _Tp = std :: basic_string; _Compare = std :: less&gt ;; _Alloc =   的std ::分配器,   std :: basic_string>取代; std :: map< _Key,_Tp,_Compare,   _Alloc> :: mapped_type = std :: basic_string; std :: map< _Key,_Tp,_Compare,_Alloc> :: key_type = std :: basic_string]'丢弃限定符[-fpermissive]

#ifndef CONCRETEREQUEST_H
#define CONCRETEREQUEST_H
#include "RequestFactory.h"
#include "Request.h"
#include "MasterFile.h"
#include <map>
#include <string>
#include <iostream>

class ConcreteRequest : public RequestFactory
{
  Request *createRequest(const std::map<std::string,std::string> &input) const
  {
    std::cout << "==Starting createRequest==" << std::endl;
    Request *pRequest;

    if (input["dataset"] == "masterfile")
      {
        pRequest = new MasterFile(input);
      }

    std::cout << "==Finishing createRequest==" << std::endl;
    return pRequest;
  }
};
#endif

这是if比较。为什么呢?

0 个答案:

没有答案