Thread: need help with exporting DLL with a class in it

  1. #1
    Registered User
    Join Date
    Nov 2002
    Posts
    319

    need help with exporting DLL with a class in it

    //this is my DLL code
    Code:
    #include "stdafx.h"
    #include <stdio.h>
    
    extern "C" __declspec(dllexport)void test();
    
    BOOL APIENTRY DllMain( HANDLE hModule, 
                           DWORD  ul_reason_for_call, 
                           LPVOID lpReserved
    					 )
    {
        return TRUE;
    }
    
    class __declspec(dllexport) MyClass
    {
    int myInt;
    };
    
    extern "C" __declspec (dllexport) MyClass;
    //this compiles fine , i copy dll.dll and dll.lib to the cpp where main is ...
    //this is the main cpp file

    Code:
    #include <iostream.h>
    #pragma comment(lib , "dll.lib")
    
    extern "C" __declspec (dllexport) MyClass;
    
    
    
    
    int main()
    {
    
       MyClass My; //but i am unable todo this ???????????
    
        return 0;
    }

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    you do not expect to export class as a C feature?

    PS.
    #include <iostream.h> - it is outdated
    use <iostream>
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Registered User
    Join Date
    Nov 2002
    Posts
    319
    can anone help?,

  4. #4
    Registered User
    Join Date
    Mar 2005
    Location
    Mountaintop, Pa
    Posts
    1,058
    Maybe an example will help you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calling a class member through a pointer to a class in a DLL
    By cboard_member in forum C++ Programming
    Replies: 1
    Last Post: 04-19-2006, 10:55 AM
  2. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  3. dll communicating between each other
    By cloudy in forum C++ Programming
    Replies: 5
    Last Post: 06-17-2005, 02:20 AM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM