这是我在 .h 文件中的功能:
static std::string ReturnString(std::string some_string)
return ("\t<" + some_string + " ");
编译器 (g++ -std=c++0x -pedantic -Wall -Wextra) 抛出以下错误:
error:expected identifier before '(' token
error:named return values are no longer supported
error:expected '{' at end of input
warning: no return statement in function returning non-void [-Wreturn-type]
但,
static std::string ReturnString(std::string some_string)
{
return ("\t<" + some_string + " ");
}
工作正常。甚至,
static std::string ReturnString(std::string some_string)
{
return "\t<" + some_string + " ";
}
也可以。
有人可以向我解释一下吗?我是否缺少一些字符串的基本知识?
谢谢。