Convertin from c++ 6 to Visual studio C++ 10
-
Hi I am new in c++. Recently I am converting a C++ project to Visual Studio 10 c++ . I am getting an error.
error C2664: 'std::_Vector_iterator<_Myvec>::_Vector_iterator(const std::_Vector_iterator<_Myvec> &)' : cannot convert parameter 1 from 'int' to 'const std::_Vector_iterator<_Myvec> &'
The code is:
XNodes::iterator _tagXMLNode::GetChildIterator( LPXNode node )
{
XNodes::iterator it = childs.begin();
for( ; it != childs.end() ; ++(it) )
{
if( *it == node )
return it;
}
return NULL; //error is in here
}How to fix it? Thanks in advance, Sai
-
Hi I am new in c++. Recently I am converting a C++ project to Visual Studio 10 c++ . I am getting an error.
error C2664: 'std::_Vector_iterator<_Myvec>::_Vector_iterator(const std::_Vector_iterator<_Myvec> &)' : cannot convert parameter 1 from 'int' to 'const std::_Vector_iterator<_Myvec> &'
The code is:
XNodes::iterator _tagXMLNode::GetChildIterator( LPXNode node )
{
XNodes::iterator it = childs.begin();
for( ; it != childs.end() ; ++(it) )
{
if( *it == node )
return it;
}
return NULL; //error is in here
}How to fix it? Thanks in advance, Sai
-
Hi, Thanks. But the logic of the code is if the node matches wuth it then return it else return nothing. Thanks, Saimanti
-
The '
return it
' I suggested returnschilds.end()
that is the past-the-end iterator (a 'typed'NULL
, roughly speaking).Veni, vidi, vici.
Thank you. It worked. But now it is giving another error..
error C2451: conditional expression of type 'std::_Vector_iterator<_Myvec>' is illegal
The code below:
bool _tagXMLNode::RemoveChild( LPXNode node )
{
XNodes::iterator it = GetChildIterator( node );
if( it ) //error is here
{
delete *it;
childs.erase( it );
return true;
}
return false;
}Thank in advance, Saimanti
-
Thank you. It worked. But now it is giving another error..
error C2451: conditional expression of type 'std::_Vector_iterator<_Myvec>' is illegal
The code below:
bool _tagXMLNode::RemoveChild( LPXNode node )
{
XNodes::iterator it = GetChildIterator( node );
if( it ) //error is here
{
delete *it;
childs.erase( it );
return true;
}
return false;
}Thank in advance, Saimanti
-
I did..
bool _tagXMLNode::RemoveChild( LPXNode node )
{
XNodes::iterator it = GetChildIterator( node );
if( it != childs.end())
{
delete *it;
childs.erase( it );
return true;
}
return false;
}Is this right? Thanks, Saimanti
-
Thank you. It worked. But now it is giving another error..
error C2451: conditional expression of type 'std::_Vector_iterator<_Myvec>' is illegal
The code below:
bool _tagXMLNode::RemoveChild( LPXNode node )
{
XNodes::iterator it = GetChildIterator( node );
if( it ) //error is here
{
delete *it;
childs.erase( it );
return true;
}
return false;
}Thank in advance, Saimanti
bool _tagXMLNode::RemoveChild( LPXNode node )
{
XNodes::iterator it = GetChildIterator( node );
if( it != childs.end() ) // Fixed it
{
delete *it;
childs.erase( it );
return true;
}
return false;
}