المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Dealing with const CString ... [modified] (FIXED).



C++ Programming
03-20-2010, 05:34 AM
(probably still a bit drunk after drinking too much Bandol wines last night).

I have a 2 small functions :

void Toto( const CString& s )
{
std::stringstream ss(s.GetBuffer());
// do some stuff with the ss string.
}
void Something( )
{
CString s("some string");
Toto ( s );
}
This obviously does not compile because I cannot get call GetBuffer on a const CString.

any other solution than making a copy of the input string in the function Toto ?
void Toto( const CString& s )
{
CString s1 = s;
std::stringstream ss(s1.GetBuffer());
// do some stuff with the ss string.
}

Thanks.

Max.
Watched code never compiles.
modified on Friday, March 19, 2010 10:53 AM