//defining structure
typedef struct config_files
{
string A;
string B;
string C;
vector<string>files;
config_files() : A(""),B(""),C(""){};//initializing the variables
}FILE_TYPES;
//updating the variables in another cpp file for eg file1.cpp
void XXX::aaa()
{
FILE_TYPES ffile;
ffile.A="AAA";
ffile.B="BBB";
ffile.C="CCC";
YYY::instance()->bbb(&ffile, NULL);
}
//then when we try to access the vector in another file its giving some junk value due to which it giving segentation fault in file2.cpp
void YYY::bbb()
{
if ( !ffile->files.empty() )
{
/*doing the related checks where it fails trying to access an uninitialised variable
which will be initialized in another file after executing this API .
So for this API to run successfully vector files should be empty ,which is not happening
as a result getting segmentation fault
*/
}
Try clearing the vector...it should be cleared by default, but...