如何将此字符串解析为表达式。 [英] How do I solve this string as an expression.

查看:72
本文介绍了如何将此字符串解析为表达式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在运行此代码。 GA时间表最初是在2008年运行但我在2012年运行它。所以我猜测存在某种兼容性问题。所以,下面是编码问题部分。





So I was running this code. GA Timetable which was originally running in 2008 but I run it in visual 2012. So I'm guessing there is some kind of a compatibility problem. So, below is the coding problem part.


bool Configuration::GetConfigBlockLine(ifstream& file, string& key, string& value)
{
    string line;

    // end of file
    while( !file.eof() )
    {
        // read line from config file
        getline( file, line );
        TrimString( line );

        // end of object's data
        if( line.compare( "#end" ) == 0 )
            return false;

        size_t p = line.find( '=' );
        if( p != string.npos )
        {
            // key
            key = line.substr( 0, p );
            TrimString( key );

            // value
            value = line.substr( p + 1, line.length() );
            TrimString( value );

            // key - value pair read successfully
            return true;
        }
    }

    // error
    return false;
}







错误在这里






error is here

c:\users\zahrina\documents\visual studio 2012\projects\gaschedule\gaschedule\algorithm\configuration.cpp(272): error C2275: 'std::string' : illegal use of this type as an expression
          c:\program files\microsoft visual studio 11.0\vc\include\xstring(2300) : see declaration of 'std::string'
c:\users\zahrina\documents\visual studio 2012\projects\gaschedule\gaschedule\algorithm\configuration.cpp(272): error C2228: left of '.npos' must have class/struct/union

推荐答案

更改 string.npos string :: npos ,请参阅: std :: string :: npos att c ++ reference [ ^ ]。
Change string.npos to string::npos, see, for instance: std::string::npos att c++ reference[^].


这篇关于如何将此字符串解析为表达式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆