映射上的模板参数无效 std::map< std::string, Stock*> &Stock
Invalid template arguments on map std::map< std::string, Stock*> &stocks
我有声明(或类似)
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 CDT C++11/C++0x 支持对它进行排序的步骤进行操作。
相关文章:
- 使用std::multimap迭代器创建std::list
- C++中std::resize(n)和std::shrink_to_fit之间的区别
- 来自 std::list 的迭代器 .end() 按预期返回"0xcdcdcdcdcdcdcdcd"但 .begin()
- C++17复制构造函数,在std::unordereded_map上进行深度复制
- 如何导出包含具有"std::unique_ptr"值的"std::map"属性的
- 从持续时间构造std::chrono::system_clock::time_point
- std::具有相同基类的类的变体
- std::向量与传递值的动态数组
- 使用std::vector的OpenCL矩阵乘法
- std::map<struct,struct>::find 找不到匹配项,但是如果我循环通过 begin() 到 end(),我在那里看到匹配项
- std::condition_variable::wait()如何评估给定的谓词
- 如何获取std::result_of函数的返回类型
- std::原子加载和存储都需要吗
- 将对象移动到std::shared_ptr
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 使用一个考虑到std::map中键值的滚动或换行的键
- 如何从 std::atomic 中提取指针 T<T>?
- 为什么 std::unique 不调用 std::sort?
- 使用std::函数映射对象方法
- 映射上的模板参数无效 std::map< std::string, Stock*> &Stock