One way of eliminating C4251 warning when using stl-classes in the dll-interface

后端 未结 4 1370
猫巷女王i
猫巷女王i 2020-12-08 01:08

It is not a good practice using stl-classes in the dll-interface as Common practice in dealing with warning c4251: class … needs to have dll-interface explains. An example i

4条回答
  •  粉色の甜心
    2020-12-08 01:55

    OR do the easiest thing to do, move the __declspec to the ONLY members you care to export:

    class HelloWorld
    {
    public:
        __declspec(dllexport) HelloWorld()
        {
            abc.resize(5);
            for(int i=0; i<5; i++)
                abc[i] = i*10;
    
            str="hello the world";
        }
        __declspec(dllexport) ~HelloWorld()
        {
        }
        std::vector abc;
        std::string str;
    };
    

提交回复
热议问题