Question

I have this code that work's well under VS6 but gives me errors in VS2010 :

void CGreatString::operator>> (char * lpszDest)
{
strcpy (lpszDest, str());
rdbuf()->freeze(0);
}

I have found this for something similar to my problem, but it still didn't work ...

So from what I have understand, ostrstream is deprecated in VS2010, so I tried this :

void CGreatString::operator>> (char * lpszDest)
{
ostringstream os;
string str = os().str();                     //Error 1 and 2
strcpy (lpszDest, str.c_str());
os.rdbuf()->freeze(0);                       //Error 3
}

But I still get errors :

1- error C2064: term does not evaluate to a function taking 0 arguments

2- error C2228: left of '.str' must have class/struct/union

3- error C2039: 'freeze' : is not a member of 'std::basic_stringbuf<_Elem,_Traits,_Alloc>'

Thanks!

Était-ce utile?

La solution 2

From the comments on my questions, I've been able to correct it. Thanks!

void CGreatString::operator>> (char * lpszDest)
{
    ostringstream os;
    string str = os.str();
    strcpy (lpszDest, str.c_str());
}

Autres conseils

So mini markdown doesn't work in comments. Great, that's just grate.

void CGreatString::operator>> (char * lpszDest)
{
    // copy lpszDest into my CGreatString
    // The code you write does nothing at all.
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top