Problem with vector<vector<struct>>?

DangDKhanh-2637 821 Reputation points
2021-07-17T09:01:42.76+00:00

Hi,
I'm looking for an answer to this problem, I have a functions in dllexport library like this:

Code:

struct  ST1 //define global outsize class;  
   {  
 ///...int,bool,..  
 CString abc = L"";  
                int a = 1; //  
 int b = 1; //  
 int c=-410;  
 int d=-410;  
   };  
class dllexport myclass{  
public:  
 void myfunction(bool mycase, vector<vector<ST1>>&); //can't initialize this vector.  
}  
  
//cpp  
void myclass::myfunction(bool mycase, vector<vector<ST1>>& vec){  
  
for(int i=1;...)  
{  
     vector<ST1> vec1;  
     for(int j=1;..)  
       vec1.pushback(ST1{..,..,..}); //ok  
     }  
     vec.pushback(vec1);// <--  error at this code   
}  
}  

in myproject, I call myfunction by this code:
Code:

   vector<vector<ST1>> vec;  
   myclass* cls;  
   //..initialize cls  
   cls->myfunction(true, vec); //error bad array.. at vec.pushback(vec1)  

now, I get these error:

115554-image.png

Note: this code runs fine if i use vector<vector<struct>> directly in myproject, but error occurs only after i use it through parameter in function from exportlibrary.

How i can fix this error?
Thanks you!

C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,198 questions
{count} votes

Accepted answer
  1. Viorel 103.2K Reputation points
    2021-07-17T15:16:03.537+00:00

    Maybe make sure that the Project Properties dialogs of your projects include these settings (for all of platforms):

    • Use of MFC: Use MFC in a Shared DLL,
    • Runtime Library (for Debug Configuration): Multi-threaded Debug DLL (/MDd),
    • Runtime Library (for Release Configuration): Multi-threaded DLL (/MD).
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful