Now all I'm doing is going through each and every object of my class and adding .render(int, int) function to it. I also do some other functions on them and my code gets quite huge... So can I somehow make it so that I can identify all my objects by ints, so that I can then use a for loop to set them all?
Hey, still pretty new to C++ but I think you might be able to make an array of pointers, and you can then assign each class to one pointer in the array. You can then just use a for loop with an index variable. Like this:
#include <iostream>
// example class
class myClass
{
private:
int someVar;
public:
void SetVar(int var) { someVar = var; }
int getVar() { return someVar; }
};
int main()
{
// declare 10 objects (0-9)
myClass Objects[10];
// give them some values.
for (int i = 0; i < 10; i++)
Objects[i].SetVar(i + 1);
for (int i = 0; i < 10; i++)
std::cout << Objects[i].getVar() << std::endl;
return 0;
}