3

使用 GCC 编译时出现此错误:

error: declaration of 'static int utils::StringUtils::SplitString(const std::string&, const std::string&, std::vector<std::basic_string<char> >&, bool)' outside of class is not definition

代码:

标题:

namespace utils
{
    /*
    *   This class provides static String utilities based on STL library.
    */
    class StringUtils
    {
    public:
        /**
        *   Splits the string based on the given delimiter.
        *   Reference: http://www.codeproject.com/Articles/1114/STL-Split-String
        */
        static int SplitString( const std::string&              input, 
                                const std::string&              delimiter,
                                std::vector<std::string>&       results, 
                                bool includeEmpties =           true );
    };
};

来源:

namespace utils
{
    int StringUtils::SplitString(   const std::string&          input, 
                                    const std::string&          delimiter,
                                    std::vector<std::string>&   results, 
                                    bool                        includeEmpties );
    {
    ....
    }
}
4

2 回答 2

10

去掉源文件定义末尾的分号!复制粘贴错误=)

于 2012-07-31T22:45:40.823 回答
6

我相信您需要在源文件中丢失该分号。应该:

namespace utils
{
    int StringUtils::SplitString(   const std::string&          input, 
                                    const std::string&          delimiter,
                                    std::vector<std::string>&   results, 
                                    bool                        includeEmpties ) // <--- No more semi-colon!
    {
    ....
    }
}
于 2012-07-31T22:47:01.333 回答