I have such declarations:
struct InstrumentInfo
{
std::string Name;
TradingStatus Status;
myDecimal MinStep;
std::string ISIN;
myDecimal limit_down;
myDecimal limit_up;
};
struct FortsDerivativeInfo : InstrumentInfo
{
std::string ShortIsin;
int IsinId;
std::string CodeVcb;
myDecimal StepPrice;
int LotVolume;
myDecimal exch_pay;
};
struct StockInfo : InstrumentInfo
{
int LotSize;
};
I've trited to write such code:
if (auto si = dynamic_cast<StockInfo*>(ii))
{
LOT_SIZE = si->LotSize;
}
else
{
LOT_SIZE = 1;
}
This doesn't compile, I receive "error C2683: 'dynamic_cast' : 'InstrumentInfo' is not a polymorphic type". How can I fix this error?
If I replace dynamic_cast
to static_cast
code compiles, but as static_cast
doesn't perform any runtime checks I'm afraid this will not work?