Search code examples
c++dlllinkerdllexport

If I put an argument in my default constructor, but give the argument a default value, is it still really a default constructor?


I know it's said to be a default constructor, but how does it work behind the scenes? I'm getting a "procedure entry point could not be located" error when my program tries to use my library containing class A with this default constructor. The program doesn't even use the default constructor of class A; it uses other constructors of the A. The library builds fine; the program builds fine. The DLL has been rebuilt, so it should know its own method call when it sees it. I'm actually just completely lost.

class DLLEXPORT A
{
  A(int a = 0);  //default constructor and single parameter constructor
};

Solution

  • A default constructor is any constructor that is callable with no arguments.

    When you say A x;, then this is the same as A x(0);, which is what the compiler actually calls.

    Similarly, copy constructors can have additional, defaulted arguments.