gpt4 book ai didi

c++ - map 上的无效模板参数 std::map< std::string, Stock*> &stocks

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:44:12 27 4
gpt4 key购买 nike

我有声明(或类似的)

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;
}

最佳答案

结果是eclipse错误。创建一个新项目并重新执行以下步骤 Eclipse CDT C++11/C++0x support对其进行排序。

关于c++ - map 上的无效模板参数 std::map< std::string, Stock*> &stocks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10912489/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com