Eclipse CDT 地图 std::map< std::string, Stock*> &stocks

问题描述 投票:0回答:1

我有声明(或类似声明)

std::map< std::string, Stock*> &stocks;

贯穿我的代码。 Eclipse 不喜欢这样并产生“无效模板参数”错误。

库存声明为:

class Stock {

 public:
    Stock(std::string, qbbo::Financial_status_indicator, qbbo::Security_class,
          qbbo::Current_trading_state,
          qbbo::Market_category, qbbo::Reg_sho_action);
    ~Stock();
    void setFinancialStatusIndicator(qbbo::Financial_status_indicator financialStatusIndicator);
    void setSecurityClass(qbbo::Security_class securityClass);
    void setCurrentTradingState(qbbo::Current_trading_state tradingState);
    void setMarketCategory(qbbo::Market_category marketCategory);
    void setREGShoAction(qbbo::Reg_sho_action regSHOAction);
    bool isStockTrading();

  private:
    enum StockState {
      STOCK_STATE_OK, STOCK_STATE_UNKNOWN, STOCK_STATE_UNEXPECTED_CHARACTERISTIC
    };

    std::string name;
    int inventory;
    StockState currentState;

    // Expected values initialised in constructor
    qbbo::Financial_status_indicator expectedFinancialStatusIndicator;
    qbbo::Security_class expectedSecurityClass;
    qbbo::Current_trading_state expectedCurrentTradingState;
    qbbo::Market_category expectedMarketCategory;
    qbbo::Reg_sho_action expectedRegSHOAction;

    // Actual values as set by messages
    qbbo::Financial_status_indicator financialStatusIndicator;
    qbbo::Security_class securityClass;
    qbbo::Current_trading_state currentTradingState;
    qbbo::Market_category marketCategory;
    qbbo::Reg_sho_action regSHOAction;

    void nextState();
};

我看不出这个声明有什么无效的地方,它编译得很好。是否有什么东西我遗漏了而 Eclipse 正在捕捉?

简短的独立正确示例

#include <string>
#include <map>

#include "stock.h"

int main() {
  std::map<std::string, Stock*> stocks;
}
c++ templates dictionary eclipse-cdt
1个回答
2
投票

原来是eclipse错误。创建一个新项目并重新按照步骤Eclipse CDT C++11/C++0x 支持对其进行排序。

© www.soinside.com 2019 - 2024. All rights reserved.