0

I have tried looking this up already on the web and I am still a little confused.

I am compiling a dll from c++ in visual studios and I have a parent class with a pure virtual method. The class itself is only called from within the dll and is not externally called.

#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
};

How do I call IndicatorName() or IndicatorParams() from the parent function when used with a dll?

Is it common practice to place the dll export and import in all my header files?

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

Trying to get the dll to recognize my childs runtime implementation.

Thanks

Vintle
  • 21
  • 3
  • 2
    Off-topic: give your parent class a virtual destructor. – Paul Sanders May 29 '20 at 18:22
  • I put your MAKEDLL macro in a separate header file and use `MAKEDLL` with any class I want to use directly from outside the dll. You should have `class MAKEDLL IndicatorBase {` instead of `class IndicatorBase {` if you want to use this class externally from the dll. – drescherjm May 29 '20 at 18:23
  • What is the error that you get? It is not clear how many dlls you have. Is the parent and child in the same or different dll? What do you mean by 'parent function'? – ap-osd May 29 '20 at 18:59
  • https://stackoverflow.com/questions/44124452/excel-vba-cant-find-dll-entry-point-from-a-dll-file/44177222#44177222, https://stackoverflow.com/questions/30581837/linker-error-when-calling-a-c-function-from-c-code-in-different-vs2010-project/30583411#30583411. – CristiFati May 30 '20 at 10:23

0 Answers0