编译时出现错误:
PagingInfo.hpp:35:错误:未在此范围内声明“StringBuilder”。
我已经包含了正确的头文件,但是为什么编译器找不到定义StringBuilder
?
实用程序.hpp:
#ifndef LIBFACEBOOKCPP_UTILS_H_
#define LIBFACEBOOKCPP_UTILS_H_
template<class TData, class TStr>
inline TData fromString(const TStr &str)
{
std::stringstream oss;
oss << str;
TData t;
oss >> t;
return t;
}
class StringBuilder
{
public:
inline operator const std::string () const
{
return oss.str();
}
private:
std::ostringstream oss;
};
#endif // LIBFACEBOOKCPP_UTILS_H_
分页信息.hpp
#ifndef LIBFACEBOOKCPP_PAGING_INFO_H_
#define LIBFACEBOOKCPP_PAGING_INFO_H_
#include "Utils.hpp"
namespace LibFacebookCpp
{
struct PagingInfo
{
PagingInfo(unsigned int offset_, unsigned int limit_) : offset(offset_), limit(limit_) { }
bool IsValid() const { return 0 != limit; }
void GetUri(Uri *uri) const
{
LIBFACEBOOKCPP_ASSERT(uri);
uri->query_params["limit"] = StringBuilder() << offset;
uri->query_params["offset"] = StringBuilder() << limit;
}
...
};
} // namespace LibFacebookCpp
#endif // LIBFACEBOOKCPP_PAGING_INFO_H_