I wanted to fill a vector with instances of a class named NEO like this:
vector<NEO> activeNEOs;
for(int i=0; i<50; i++){
activeNEOs.push_back(new NEO());
}
I did something similar in Processing which worked just fine but now it doesn’t work; so I tried this instead:
vector<NEO> activeNEOs;
for(int i=0; i<50; i++){
activeNEOs.push_back(*new NEO());
}
The program compiles if I do it this way even though I’m not sure this is the correct thing to do (I’m putting pointers into the vector now, right?).
After that I wanted to send some variables to the contructor of the newly created object:
for(int i=0; i<50; i++){
activeNEOs.push_back(*new NEO(data,i));
}
//NEO.h
class NEO{
NEO(string[][],int);
}
//NEO.cpp
NEO::NEO(string[][] tempData,int tempI){
}
data is a two-dimensional array and i is an int, but the program no longer compiles, gives the error 'no matching function for call to ‘NEO::NEO(std::string [(((unsigned int)(((int)((testApp*)thi…’ and I just don’t know what I’m doing anymore.
I’m not sure if I’m creating the instances of the NEO class the right way and I’m not sure if I’m using the constructor the right way
Any help would be greatly appreciated. I’ve already spend too many hours searching for help on a seemingly easy piece of coding.