Hello and thank you for viewing.
I'm using new() to make new objects and adding them to an array using a for loop.
// pre setup declaration
OBJECT arrayOfObjects[numberOfObjects];
//inside loop()
for (int i=0; i<numberOfObjects; ++i)
{
OBJECT newOBJECT;
arrayOfObjects[i]=newOBJECT; // adds newOBJECT to objects vector
arrayOfObjects[i].name = arrayOfObjectNames[i]; //assigns it the corresponding name
for(i2=0;i2<numberOfProperties;i2++){ // for all properties of each object
//assigns it the corresponding property values
arrayOfObjects[i].arrayOfObjectProperties[i2] = arrayOfPropertyValues[i2];
if(arrayOfObjects[i].arrayOfObjectProperties[i2] != 0) //testing , prints non zeros
{
Serial.println(arrayOfObjects[i].name + " " + arrayOfPropertyNames[i2] + ": " + arrayOfObjects[i].arrayOfObjectProperties[i2]); //prints non zeros (testing)
}
}
}
The class contains two types of public members; properties and arrays of those properties.
class OBJECT {
public:
String name;
int living;
int arrayOfObjectProperties[numberOfProperties];
int arrayOfObjectComparisonValues [numberOfObjects]; // only accessed by UNKNOWN
};
OBJECT UNKNOWN; //predefined object
I'm getting the error denoted by title of post when I try to iteratively compare the public property arrays of these dynamically instantiated objects with a. integers (eg 1) or b. the same array of another, predefined and uninitialized object of the same class.
// if value of an object's property contradicts that of UNKNOWN
if(UNKNOWN.arrayOfObjectProperties!=arrayOfObjects[i].arrayOfObjectProperties[i2]) {
// i corresponds to number of objects, i2 the number of properties
I've tried putting the new(object) substantiation in the setup() but obviously that didn't solve the problem.
I'm assuming I need to return a value somewhere or use some kind of pointer.
Your help is greatly appreciated.