I have these data members static because Array will be an abstract class that will have have multiple classes that will inherit it. I want to be able to load data from a text file into my primaryCollections array.
Keep getting an error when I try to compile my code:
/usr/bin/ld: Array.o: warning: relocation against `_ZN5Array17primaryCollectionE' in read-only section `.text' /usr/bin/ld: Array.o: in function `Array::loadData(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)': Array.cc:(.text+0x240): undefined reference to `Array::primaryCollection' /usr/bin/ld: warning: creating DT_TEXTREL in a PIE collect2: error: ld returned 1 exit status make: *** [Makefile:6: p1] Error 1
Array.cc:
//loads data from text file into a list of record objects
void Array::loadData(string f){
  int year, employed, graduates;
  string province, degree, gender;
  ifstream file(f, ios::in);
  if (!file) {
    cout << "Error: could not open file" << endl;
    exit(1);
  }
  while ( file >> year >> province >> degree >> gender>> employed>> graduates ) {
    Record *record = new Record(year,province,degree,gender,employed,graduates);
    primaryCollection.push_back(record);
  }
  
}
Array.h:
class Array {
  
  public:
    static void loadData(string);
    
  private:
    string name;
    static vector<Record*> primaryCollection;
  
};
 
     
    