我在主窗口中遇到奇怪的链接错误。我还在主窗口中包含了这些类的头文件。但它仍然无法链接虚拟功能。
我正在使用main中的以下代码:
S3W::IFields *recordsTx = pConnection->GetTransmittedFields();
FieldsDataList *derived = dynamic_cast<FieldsDataList*>(recordsTx);
for (int j = 0; j < 2; j++)
{
VarField& record = derived->CreateDataItem();
FieldsDataList *fields = record.getChildrenDataList();
VarField& fieldGeom1 = fields->CreateDataItem();
fieldGeom1.SetKey("geom");
double x = 47;
double y = 16;
fieldGeom1 = VarField::fromGPS(new ImplGps(x, y));
}
我收到以下链接错误:
3>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual struct S3W::IFields & __thiscall VarField::getChildern(void)" (?getChildern@VarField@@UAEAAUIFields@S3W@@XZ)
3>MainWindow.obj : error LNK2001: unresolved external symbol "public: virtual struct FieldsDataList * __thiscall VarField::getChildrenDataList(void)"
以下是类的类定义:
//伪代码
class VarField : public S3W::IField
{
virtual S3W::IFields& getChildern() override;
// Inherited via IField
virtual FieldsDataList * getChildrenDataList() override;
}
和IField是:
struct FieldsDataList;
namespace S3W
{
struct IFields;
struct IField : S3W::IListItem
{
enum class Type { NONE = 0, UINT = 1, DOUBLE = 2, STRING = 3 , GEOM = 4};
virtual S3W::IGps* getGeom() = 0;
virtual double getDouble() const = 0;
virtual unsigned int getUint() const = 0;
virtual const char* getString() const = 0;
virtual const char* getKey() const = 0;
virtual Type getType() const = 0;
virtual ~IField() { }
IField() {}
virtual IFields& getChildern()= 0;
virtual FieldsDataList* getChildrenDataList() = 0;
};