我结构:
struct User {
~User();
Datacratic::Id id; ///< Exchange-specific user ID
Datacratic::Id buyeruid; ///< Exchange seat-specific user ID
Datacratic::TaggedInt yob; ///< Year of birth
std::string gender; ///< Gender: Male, Female, Other
Datacratic::CSList keywords; ///< List of keywords of consumer intent
Datacratic::UnicodeString customdata; ///< Custom data from exchange
Datacratic::Optional<Geo> geo; ///< Geolocation of user at registration
std::vector<Data> data; ///< User data segments
Json::Value ext;
}
当我通过user.gender
引用性别时,它会说:
error: âstruct Datacratic::Optional<OpenRTB::User>â has no member named âgenderâ
result->segments.addStrings("gender", result->user.gender);
谢谢, 安
答案 0 :(得分:0)
从编译器错误中我看起来result->user
属于OpenRTB::User
类型,可能与您的struct User
类不同。因此,您要么result->user
类型User
,要么扩展OpenRTB::User
类并添加其他字段。然后,您可以通过动态转换为OpenRTB::User *
来访问User *
中的字段。