How do i export class that fully defined in header file?

721 Views Asked by At

DLL Library:

// export.h
    #if defined(COMMON_EXPORT)
        #define COMMON_DLL __declspec(dllexport)
    #else
        #define COMMON_DLL __declspec(dllimport)
    #endif
// foo.h
class COMMON_DLL Foo
{
    int foo() { return 1; }
}

if i try to invoke this code from other library, then linker error happened. If remove COMMON_DLL from foo.h or move implementation of foo() method to .cpp file, then all work fine. Why is it so?

0

There are 0 best solutions below