c++ - Qt c++ 聚合 'std::stringstream ss' 类型不完整,无法定义

标签 c++ string qt stringstream

我的程序中有这个函数可以将整数转换为字符串:

    QString Stats_Manager::convertInt(int num)
    {
        stringstream ss;
        ss << num;
        return ss.str();
    }

但是当我运行它时,我得到了错误:

aggregate 'std::stringstream ss' has incomplete type and cannot be defined

我不太确定这意味着什么。但是,如果您知道如何修复它或需要更多代码,请发表评论。谢谢。

最佳答案

你可能有一个类的前向声明,但没有包含标题:

#include <sstream>

//...
QString Stats_Manager::convertInt(int num)
{
    std::stringstream ss;   // <-- also note namespace qualification
    ss << num;
    return ss.str();
}

关于c++ - Qt c++ 聚合 'std::stringstream ss' 类型不完整,无法定义,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11751486/

相关文章:

c++ - 使用 xdelta : header file not found. c++

c++ - 如何在 C++ 中滚动锁定报表样式 ListView 的第一列

c++ - void operator()() 的功能

Java:按字符数分割字符串,但保证字符串仅在空格之后分割

c++ - QTreeWidget 中的稳定排序 QTreeWidgetItems?

c++ - QProgressDialog : How to adjust the size of the dialog to fit its contents?

c++ - Qt - 保持指向存储在 QList 中的内容的指针的最佳方法是什么?

python - Python 中的连续子字符串

python - 循环比较字符串列表元素与字符串列表子元素的有效方法

qt - QLinearGradient 不能与 QBrush 一起正常工作