C++ 由于链接中缺少虚拟函数,无法解析外部
主窗口中出现奇怪的链接错误。我还在主窗口中包含了这些类的头文件。但它仍然无法连接虚拟功能 我主要使用以下代码:C++ 由于链接中缺少虚拟函数,无法解析外部,c++,C++,主窗口中出现奇怪的链接错误。我还在主窗口中包含了这些类的头文件。但它仍然无法连接虚拟功能 我主要使用以下代码: S3W::IFields *recordsTx = pConnection->GetTransmittedFields(); FieldsDataList *derived = dynamic_cast<FieldsDataList*>(recordsTx); for (int j = 0; j < 2; j++) {
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));
}
以下是类的类定义:
//伪码
class VarField : public S3W::IField
{
virtual S3W::IFields& getChildern() override;
// Inherited via IField
virtual FieldsDataList * getChildrenDataList() override;
}
我的领域是:
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;
};
我只看到这两个函数的声明,它们的定义在哪里?
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;
};