Pure virtual calls not resolving

Using VS 2022 Version 17.14.25
Having trouble getting pure virtual calls to link.
I have a solution with a main project and several DLLs.
The main class inherits a class from one of the DLLs.

In one of the DLLs:
1
2
3
4
5
6
7
8
class STARTUP : public std::vector<std::string>
{
public:
    //  Push the arguments into the vector
    STARRTUP (int argc, LPCSTR argv[]);
    // Process the arguments one at a time
    void process_arg(const std::string & arg) = 0;  // pure virtual
}


In the main program:
1
2
3
4
5
6
7
8
9
10
11
12
13
MainClass::MainClass(int argc, LPCSTR argv) : STARTUP(argc, argv)
{}

//  Overload
void MainClass::process_arg(const std::string & arg)
{
//  Process one argument
}

int main (int argc, LPCSTR argv[])
{  MainClass myprog(argc, argv);
  ...
}


When run, the program invokes the STARTUP constructor which saves the arguments to the vector, then it begins to iterate through the arguments. It traps on the first call to process_arg() which is pure virtual. It's not resolving the reference to the instance of process_arg() in MainClass().

I've played with the order that the DLLs are loaded, that doesn't make any difference.
I've also made sure in the optimization options, that eliminate unused code is off

What am I missing? Shouldn't I be able to resolve a pure virtual call from a DLL back to the main module?
Last edited on
AbstractionAnon wrote:
When run, the program invokes the STARTUP constructor which saves the arguments to the vector, then it begins to iterate through the arguments.

If process_arg is called from the STARTUP constructor it will try to call STARTUP::process_arg and not MainClass::process_arg.
Last edited on
Got it. Thanks.
Registered users can post here. Sign in or register to post.