Still same problem

Continuing the discussion from String array error:

Well, I put it as global but it’s not working also, it says:

no matching function for call to create, I really don’t know how to do that, I tryed using that d list…same error

While I think a vector would be overkill for your purposes, it probably is the easiest to use. (Unfortunately list doesn’t seem to have an easy way to get an item by index.) So just try this:

class Color {
private:
...
const static std::vector<std::string> stringTeste;
...
};

And in your source file, outside of any function:

const std::vector<std::string> Color::stringTeste = { "a.png", "b.png" };

So, for example:

#include "Color.h"

const std::vector<std::string> Color::stringTeste = { "a.png", "b.png" };

Color::Color() {
   ...
}

It’s worth using something like list or vector because then you can use size() to get how many items it has, so if you add extra items later you won’t need to remember to change the total number when picking a random item. So you could then pick a random item using:

cor = rand() % stringTeste.size();

And choose the item using stringTeste.at(cor).

Thanks for helping me grimfate, you rock, sorry if I made you type the code, I’m really glad!!!