类外静态函数的声明不是定义
declaration of static function outside of class is not definition
使用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 );
{
....
}
}
去掉源文件中定义末尾的分号!复制粘贴错误=)
我认为您需要丢失源文件中的分号。应为:
namespace utils
{
int StringUtils::SplitString( const std::string& input,
const std::string& delimiter,
std::vector<std::string>& results,
bool includeEmpties ) // <--- No more semi-colon!
{
....
}
}
相关文章:
- 如何确保C++函数在定义之前声明(如override关键字)
- 为什么在定义函数之前先声明它
- 为什么我不能在一个类的不同行中声明和定义成员变量?
- Visual Studio中的函数声明和函数定义问题
- C++错误C2600:无法定义编译器生成的特殊成员函数(必须首先在类中声明)
- 如何在标头中声明(或定义)函数的问题
- 程序顶部的声明与定义(最佳实践)
- 类的前向声明之后的类成员函数定义,在类声明之前
- 静态变量声明和定义
- C++ G++ 编译器 - 错误:隐式声明的定义
- C++:错误重定义和先前声明
- 类模板静态数据成员定义/声明/初始化
- 只有一个定义/声明时标头声明变量的多堆定义错误
- OpenCV - Ptr 语法和类定义/声明 - 混淆?
- 如何为非类型模板类的专用化定义声明之外的方法
- 我如何防止静态类成员变量需要两个定义/声明
- 默认定义声明的详细程度不完整
- C++:非成员函数的定义/声明的位置
- 将比较操作符的重载定义/声明为库中的非成员函数
- C++头重新定义/声明混合