相关疑难解决方法(0)

会员模板功能.为什么不编译?

我想在列表中迭代成员函数.在此代码示例中,我在for-line中遇到编译器错误:

预期; 在它之前,它没有宣布,结束没有宣布.

为什么?该功能甚至没有在代码中使用!

template <class T> bool Settings::saveSimpleList( QString k, const T & l ){
    //...
    for ( T::ConstIterator it = l.constBegin(), end =l.constEnd(); it != end; ++it )
    {
        QString itemValue = QVariant( *it ).toString();
        //...
    }

    return true;
}
Run Code Online (Sandbox Code Playgroud)

我明白了,我在模板编程中遗漏了一些东西.谢谢你的提示!

c++ templates

2
推荐指数
1
解决办法
115
查看次数

标签 统计

c++ ×1

templates ×1