Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not necessary to export class with only virtual/inline functions?

Tags:

c++

dll

winapi

In C++ on Win32:

Suppose I have a DLL with a header file that declares a class. The DLL exports some means of obtaining a pointer/reference to an instance of that class, such as a factory function.

Am I correct in believing that it is not necessary to mark that class as exported using __declspec if one is only going to call virtual or inline functions on its instances?

Conversely, is it necessary to export the class declaration if one wishes to call nonvirtual member functions?

like image 200
kbluck Avatar asked Feb 14 '09 23:02

kbluck


1 Answers

Am I correct in believing that it is not necessary to mark that class as exported using __declspec if one is only going to call virtual or inline functions on its instances?

Yes,this is correct, and that's what COM do, the DLL only expotys 4 methods, one of them returns to the class factory, which all its members are pure virtual functions.

Conversely, is it necessary to export the class declaration if one wishes to call statically defined member functions?

No, just export the static member functions.

like image 106
Bahaa Zaid Avatar answered Sep 28 '22 03:09

Bahaa Zaid