将C ++ 11代码转换为C ++ 98

时间:2014-02-22 20:11:26

标签: c++ c++11 c++98

代码:

while ((row = mysql_fetch_row(pRes))) {
        TMPTable temp = {};
        if (row[0]) temp.con = strtoul(row[0], NULL, 10);
        std::vector<MATable>.push_back(temp);
}

TMPTable temp = {};

时出错

in C++98 'temp' must be initialized by constructor, not by '{...}'

另一个问题是:

std::ostringstream query;

给出错误:

aggregate 'std::ostringstream query' has incomplete type and cannot be defined

我在google上尝试过这些解决方案,但还没找到任何有效的解决方案......总是以错误结束。你们能指出我正确的方向吗?

1 个答案:

答案 0 :(得分:6)

您需要添加<sstream>才能获得std::ostringstream的定义。要解决初始化问题,您只需使用

即可
TMPtable tmp = TMPtable();