Put the definition of the class in a header file and include it in whatever you want to share the class with. If you want an instance of the class (an object), you can put that in a DLL and share it.
Yes, with vc++ you best create a sample win32 dll that exports a few symbols and see how it's done.
With others I don't know how, but it's surely possible.
What do you mean 'export the class' ? You can put an instance of a class in a DLL and share it with your exe code. You don't get the class definition from the DLL.
I think if you made the class COM-compatible you could probably register it with Windows and let Windows deal with it.
Ok, the DLL compiles fine, but I get a link error when I try to write a simple program using the class. I attached my source so you can see where it went wrong.
error LNK2001: unresolved external symbol "__declspec(dllimport) class MyClass inst" (__imp_?inst@@3VMyClass@@A)
Alcohol & calculus don't mix.
Never drink & derive.
You need two copies of the header. One to create the DLL, and one to use it. I use a preprocessor directive to decide what to use, that way I can get by with the same header. A specific symbol is defined in project settings for the DLL project.
I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You". -- Linus Torvalds
Ah right that code was meant for the headers not the DLL.....
Hang on a minute... that's what I was suggesting in the first place, minus the __declspec bit. What's that for that just including the class definition wouldn't do?
It tells the linker not to search for the class in a normal library or module, but rather the import library. (I think)
Also, I'm not sure if I posted the right files before. Tell me if not.
All the buzzt CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.