CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Aug 2001
    Location
    Germany
    Posts
    1,384

    Placement new with HeapAlloc

    Hi*!
    I have a Dll that dll implements a class. I have a class factory kindof function in the DLL that gives me an Object of the class in DLL. I dont want to include any libs in my project for the DLL. The class factory in the Dll does something like
    PHP Code:
    // Doing some other stuff too
    voidpMem HeapAlloc(GetProcessHeap(), 0sizeof(CMyDllClass)); 
    return new (
    pMemCMyDllClass(); 
    Is it correct??? It works but i want to know if theres a more appropriate way to achieve the same????
    Secondly when i dont need the object, what should i do???? delete will also i think delete the memory & If i use Heap functions to delete the memory, then do i have to call the dtor myself?????
    Thanks for ur time,
    Regards,
    Usman.
    Last edited by usman999_1; May 10th, 2003 at 05:24 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured