1

我的代码在 VS6 下运行良好,但在 VS2010 中出现错误:

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

我发现这个问题类似于我的问题,但它仍然没有工作......

所以据我了解, ostrstream 在 VS2010 中已被弃用,所以我尝试了这个:

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
}

但我仍然收到错误:

1- 错误 C2064:术语不计算为采用 0 个参数的函数

2-错误C2228:'.str'的左边必须有类/结构/联合

3- 错误 C2039:“冻结”:不是“std::basic_stringbuf<_Elem,_Traits,_Alloc>”的成员

谢谢!

4

2 回答 2

0

从对我的问题的评论中,我已经能够纠正它。谢谢!

void CGreatString::operator>> (char * lpszDest)
{
    ostringstream os;
    string str = os.str();
    strcpy (lpszDest, str.c_str());
}
于 2012-05-17T13:05:50.637 回答
0

所以迷你降价在评论中不起作用。太好了,这只是炉排。

void CGreatString::operator>> (char * lpszDest)
{
    // copy lpszDest into my CGreatString
    // The code you write does nothing at all.
}
于 2012-07-17T08:54:12.557 回答