jeudi 2 décembre 2021

How come push_back function would not work with the class enum? [closed]

I need to have the generated cell(s) to be stored in a vector I created. The push_back function would not let me run the code and states that there is no instance of overloaded function and it only shows the error when I put in the class enum inactive (if I remove it, there is no problem). Is there any way to pushback the value of the class enum (alive or dead) in the vector?

ofApp.cpp

for (i = 0; i < 5; i++){
  for (j = 0; j < 11; j++) {    
     xPos = initialX + (initialX * i);
     yPos = initialY + (initialY * j);
     cells.push_back({10, 10, 10, 10, inactive});
  }
  i = 0;
}

ofApp.h

class ofApp : public ofBaseApp {
public:
   std::vector<step> cells;
   status active = status::alive;
   status inactive = status::dead;
};

gridStep.h

#pragma once
  struct step {
    float xloc;
    float yloc;
    float cellHeight;
    float cellWidth;
    enum class status {
      alive,
      dead
  };
};

Aucun commentaire:

Enregistrer un commentaire