首页 > 解决方案 > DLL 纯虚函数

问题描述

我已经尝试在网上查找此内容,但我仍然有点困惑。

我正在 Visual Studio 中从 c++ 编译一个 dll,并且我有一个带有纯虚拟方法的父类。类本身仅在 dll 内调用,不从外部调用。

#pragma once

#include <string>
class IndicatorBase {
    public:
        IndicatorBase(const char*, int);            // Constructor
        double GetValue();                          // Gets the value from the indicator
    protected:
        const char* symbol;
        int period;
        int handle;                                 // Handle for indicator
        void SetupIndicator();                      // Creates the indicator
        virtual const char* IndicatorName() = 0;            // Returns the Indicator Name
        virtual void IndicatorParams(std::string & buff) = 0;   // Sets the buffer sent in to the parameters
};

与 dll 一起使用时,如何从父函数调用 IndicatorName() 或 IndicatorParams()?

将 dll 导出和导入放在我所有的头文件中是常见的做法吗?

#ifdef MAKEDLL
#  define EXPORT __declspec(dllexport)
#else
#  define EXPORT __declspec(dllimport)
#endif

试图让 dll 识别我孩子的运行时实现。

谢谢

标签: c++dll

解决方案


推荐阅读