1

我正在使用 boost 库来解析 .ini 文件,如下所示:

[head]
type1=val1
type2=cal2
...

我的代码是这样的:

#include <iostream>
#include <string>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
using namespace std;

int main()
{
    using boost::property_tree::ptree;

    boost::property_tree::ptree pt;
    boost::property_tree::ini_parser::read_ini("test.ini", pt);

    boost::property_tree::ptree::iterator pos1,pos2;

    for(pos1 = pt.begin(); pos1 != pt.end() ; ++pos1)
    {
        cout << pos1->first << endl;

        for(pos2 = pos1->second.begin() ; pos2 != pos1->second.end() ; ++pos2)
        {
            cout << "    " << pos2->first << "=" << pos2->second.get_value<string>() << endl;
        }
        cout << endl;
    }

    return 0;
}

一切正常,程序输出符合预期,但 Eclipse 将所有 pos1 和 pos2“->”标记为错误......智能感知不会加载“第一个”或“第二个”选项并将它们的所有使用标记为错误。 ..但一切都编译...

有任何想法吗 ??

这是它的外观:

在此处输入图像描述

4

1 回答 1

0

pos1并且pos2不是指针,您应该使用.而不是->

于 2014-11-17T03:02:15.487 回答