Please help me.When I try to access the vector of the structure (elmCom) that I define, the program suddenly ends.The vector (named elcom and very confusing) is defined in the header file, then the constructor in ObdCapture.cpp has secured memory, and the init method pushes data from xml (approximately 800 lines) to elcom.After pushing_back, you can check the size by elcom.size(), but when you try to see the value of the structure inside the vector or try to access it using an iterator, it suddenly ends like that way.There was no specific error output.
If it's a segmentation error, it seems to come out normally.
The development environment is raspbian (raspberry pi).I apologize for the poor writing and code.
Thank you for your cooperation.
The constructor in the ObdCapture class says elcom(138), which means that the member variable elcom contains 138 elmCom objects from the beginning that already have an indefinite value before pushback.
If you try to read this indefinite value of code as a string (i.e., cout<elcom.at(0).code<endl;), the indefinite value of code points to an invalid memory area, so the program crashes. elcom(138) should be fixed by setting the elcom().
It's not directly related to the question, but let me give you some advice.
You seem to be able to write a reasonable amount of code, and you seem to have the ability to find out the libraries you need. I think it will be much easier to program than it is now if you take time to learn how to write code, techniques, etc. I recommend reading "Effective C++ and C++ Coding Standards.