Thread: DLL and new operator

  1. #1
    char main() RoshanX's Avatar
    Join Date
    Mar 2003
    Posts
    68

    DLL and new operator

    hi,

    Can I dynamically create an object and return a pointer to that object to the main program from inside a function that is exported from a DLL ?
    First there was God. He was quite lonely, so he created Dennis.
    Dennis was unimpressed with God.
    So, . . . God created Brian..........Khan Klatt
    http://www.clifford.at/fun/GOD

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,268
    Yes.

  3. #3
    char main() RoshanX's Avatar
    Join Date
    Mar 2003
    Posts
    68
    then why wouldn't this work :

    Code:
    /* class A is an abstract class */
    class A
    {
         
    }
    
    class B: public A
    {
    
    }
    in main.cpp

    Code:
    A* __declspec(dllexport)  get_A()
    {
                A* a =new B();
               return a;
    }
    if I just returned a NULL, this would work ( with some other error message), but if I do it like this it will give me "Run-Time Check Failure #0- The value of ESP was not properly saved across a function call. This is usually a result of calling a function ............"
    First there was God. He was quite lonely, so he created Dennis.
    Dennis was unimpressed with God.
    So, . . . God created Brian..........Khan Klatt
    http://www.clifford.at/fun/GOD

Popular pages Recent additions subscribe to a feed