Hi,
I tried to share some data between 2 .cc files hence declared the arrays of structure as extern in one of the .cc files.
However I get abnormal entries in the original array entries otherwise I wouldn't have got.
file1.h
---------
struct Mylistdetails {
int id;
int value;
}
file1.cc
----------
struct Mylistdetails myList_[MAX_NO];
file2.cc
-----------
#include <file1.h>
extern struct Mylistdetails myList_[MAX_NO];
The purpose here is to call these array data into the file2.Here,myLi st_[i].id and myList_[i].value are just unexpected once declared as 'extern'.If not used this extern method the expected values are observed once only file2 is being used.
Could you kindly specify the behaviour of this.Many thanks for your advise on how to tackle such a problem.
I tried to share some data between 2 .cc files hence declared the arrays of structure as extern in one of the .cc files.
However I get abnormal entries in the original array entries otherwise I wouldn't have got.
file1.h
---------
struct Mylistdetails {
int id;
int value;
}
file1.cc
----------
struct Mylistdetails myList_[MAX_NO];
file2.cc
-----------
#include <file1.h>
extern struct Mylistdetails myList_[MAX_NO];
The purpose here is to call these array data into the file2.Here,myLi st_[i].id and myList_[i].value are just unexpected once declared as 'extern'.If not used this extern method the expected values are observed once only file2 is being used.
Could you kindly specify the behaviour of this.Many thanks for your advise on how to tackle such a problem.
Comment