C++ Builder编译时奇怪的问题
头文件中已经声明了这2个函数,可是编译的时候抱错,说该函数不是类的成员
查了半天找不到原因,郁闷
头文件:
class string_aux
{
public:
static int toint(const string & s);
static string trim(const string & s);
};
源文件:
string string_aux::trim(const string & s)
{
const char *p1 = s.c_str();
while (*p1 == '\t ' || *p1 == ' ') ++p1;
const char *p2 = s.c_str() + s.size() -1;
while (p2 > = p1 && (*p2 == '\t ' || *p2 == ' ')) --p2;
return (p2 > = p1) ? string(p1, p2-p1+1) : string( " ");
}
int string_aux::toint(const string & s)
{
return atoi(s.c_str());
}
[解决办法]
大小写问题
String 属性问题
[解决办法]
static string string_aux::trim(const string & s)
{
const char *p1 = s.c_str();
while (*p1 == '\t ' || *p1 == ' ') ++p1;
const char *p2 = s.c_str() + s.size() -1;
while (p2 > = p1 && (*p2 == '\t ' || *p2 == ' ')) --p2;
return (p2 > = p1) ? string(p1, p2-p1+1) : string( " ");
}
static int string_aux::toint(const string & s)
{
return atoi(s.c_str());
}
[解决办法]
程序语法上没问题,请在.h文件头上加:
#include <string>
using namespace std;