In a VC dll project, when we export a class which contains a not exported class variable, VC will have a warning(C4251).
For example,
- class A
- {
- private:
- int m_i;
- };
- class __declspec(dllexport) B
- {
- private:
- A m_a;
- };
VC will complain:
warning C4251: 'B::m_a' : class 'A' needs to have dll-interface to be used by clients of class 'B'
To work around this problem, we can change the member variable definition like below:
- class A
- {
- private:
- int m_i;
- };
- class __declspec(dllexport) B
- {
- private:
- A* m_pa;
- };