C2664: typecast problem from iterator to class type

I have some iterator and some CForm class.

vector<CForm>::const_iterator* m_pvForms;

Then it is initizalized etc.

After:

1
2
3
4
5
6
7
8
vector<CForm>::const_iterator itB = m_pvForms->begin();
vector<CForm>::const_iterator itE = m_pvForms->end();
vector<CForm>::const_iterator it;

for (it = itB; it != itE; ++it)
{
    string test = GetTableName(it);
}


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.
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.
That hepled, many thanks.
Topic archived. No new replies allowed.