I have a old c++ code, wirited and compiled into c++ builder 5. But now, I need to update/migrate this code to c++ builder 2009. So, I have some problems:
int __fastcall TAllConversor::ListToStr(
const TStringList* pList,
AnsiString& strValue,
const long lngLimiteInferior,
const long lngLimiteSuperior) const
{
long lngIndice;
AnsiString strAux;
try
{
if (lngLimiteSuperior == 0)
lngIndice = pList->Count;
else
lngIndice = lngLimiteSuperior + lngLimiteInferior;
for (int i = lngLimiteInferior; i < lngIndice; i++)
{
strAux += pList->Strings[i] + ";";
}
strValue = strAux;
return 1;
}
catch(...)
{
return 0;
}
}
At line "lngIndice = pList->Count;" I get this error: "E2522 Non-const function _fastcall TStrings::GetCount() called for const object".
So, how can I solve (work around) it?
TStringListis a VCL class. ItsCountproperty calls theGetCount()method.