[SOLVED] [STUPID] ISO C++ forbids comparison between pointer and integer

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.

It is difficult to tell what you intended because you only posted a snippet of your code. However...

UNKNOWN.arrayOfObjectProperties is the address of (pointer to) UNKNOWN.arrayOfObjectProperties[0].

arrayOfObjects_.arrayOfObjectProperties[i2] is an int. Of course you cannot compare these._ Perhaps you intended UNKNOWN.arrayOfObjectProperties to be UNKNOWN.arrayOfObjectProperties[i2], I cannot tell, I am only guessing.

Duuuuuuuuuuuhh.......

I'm sorry, stupid typo style mistake. This reason I suspected there was something fundamentally wrong is because I've been trying to learn more about C++ and stepping outside the arduino sphere for a bit, got used to using things like vectors and have had to rethink some things now returning to arduino without the full std lib.