SteveBrett
Programmer
hello all,
this is driving me crazy !!!
i need to replace all the occurences on '&' with '&' in a string of xml but can't seem to get the paramters of the insert function correct.
the string is defined as:
std::wstring m_objStrReturnXml;
this is the code i have as present:
const char *escamp = "amp;";
for(int x=0; x < m_objStrReturnXml.length(); x++)
{
if (m_objStrReturnXml[x] == '&')
{
m_objStrReturnXml.insert(x+1, escamp);
}
}
when i try to build it i get:
error C2664: 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &__thisca
ll std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::insert(unsigned int,const class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigne
d short> > &)' : cannot convert parameter 2 from 'const char *' to 'const class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &'
Reason: cannot convert from 'const char *' to 'const class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >'
No constructor could take the source type, or constructor overload resolution was ambiguous
this is driving me crazy !!!
i need to replace all the occurences on '&' with '&' in a string of xml but can't seem to get the paramters of the insert function correct.
the string is defined as:
std::wstring m_objStrReturnXml;
this is the code i have as present:
const char *escamp = "amp;";
for(int x=0; x < m_objStrReturnXml.length(); x++)
{
if (m_objStrReturnXml[x] == '&')
{
m_objStrReturnXml.insert(x+1, escamp);
}
}
when i try to build it i get:
error C2664: 'class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &__thisca
ll std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >::insert(unsigned int,const class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigne
d short> > &)' : cannot convert parameter 2 from 'const char *' to 'const class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> > &'
Reason: cannot convert from 'const char *' to 'const class std::basic_string<unsigned short,struct std::char_traits<unsigned short>,class std::allocator<unsigned short> >'
No constructor could take the source type, or constructor overload resolution was ambiguous