Click here to Skip to main content
15,886,664 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I want to dllexport a class for acessing its pointers and member functions.Is there any way of doing it without adding that class's header file?
Posted
Updated 30-Mar-11 20:14pm
v2

You don't really need a header file to export a class, but you need the class declaration to import it, in the form of header file or not. Not using header files makes no sense and would be extremely inconvenient is you need to use the declaration in more then one C++ file.

—SA
 
Share this answer
 
Comments
Albert Holguin 31-Mar-11 17:29pm    
very right, my 5
Sergey Alexandrovich Kryukov 31-Mar-11 17:35pm    
Thank you, Albert.
--SA
Yes: you might invent COM.
 
Share this answer
 
You don't specifically need the header file, but you do need the class definition which is typically in the header file (without this, you can't compile).
Usually, the header file contains additional includes which are required for the class definition, f.e. windows.h if one of the member variables has type HWND.

If the reason you can't add the header file is that it gives a compile error, you could try copy the class definition and include only the files needed for that and skip the rest.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 31-Mar-11 2:44am    
You apparently understand it all correctly and all your advice is correct, but maybe you misread the OP question, who asks about header file for export. It is useful for import, but not really for export... I suggest you make it more clear.

Please see my Answer.
--SA
[no name] 31-Mar-11 3:06am    
Although the word export is indeed mentioned, I do not think this is the question.
Your answer is valid though if you choose to interpret the question like that.
Sergey Alexandrovich Kryukov 31-Mar-11 3:13am    
Sure. Well, then this is an error in formulation of the Question, which is explainable. By the way, I answered the way which fits any interpretation -- just the fact, so there is not "if". That was the reason I was careful in wording an tried to suggest the same for you.
--SA
If you just want to hide all the private and protected members and possible inlined functions in the header inside intellisense (given your IDE has that) you may think about making the class visible trough an interface and provide the header of that interface. Then you can stick to the public members and nothing is shown that is not public (or any kind of implementation).

Is that what you are aiming for?

Yanick
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900