C2664: typecast problem from iterator to class type
| DmitryG (3) | |||
I have some iterator and some CForm class.
vector<CForm>::const_iterator* m_pvForms;Then it is initizalized etc. After:
Method
GetTableName accepts
const CForm* parameter.In Visual Studio 6.0 everything in fine but in VS.NET 2003 compiling fails with error: error C2664: 'CDialogSelectForm::GetTableName' : cannot convert parameter 1 from 'std::vector<_Ty>::const_iterator' to 'const CForm *' with [ _Ty=CForm ] No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called I think there is some more strict typecast policy in VS.NET rather than VS6... Help please, i'm totally stuck. Sorry for my English and thanks. | |||
| Duoas (1458) | |||
It is because iterators are classes themselves, not just pointers. You need to first dereference the iterator, and then get the address of the CForm object:
string test = GetTableName( &(*it) );I think that should do it for you. | |||
| DmitryG (3) | |||
| That hepled, many thanks. | |||
This topic is archived - New replies not allowed.
