I have a file which contains arrays of strings representing some icons.
static constexpr char icons1[2][40] = {
"icon1_A", "icon1_B"
};
static constexpr char icons2[3][30] = {
"icon22_A", "icon2_B", "icons2_C"
};
Then I have a class that wants to be initialized with a reference to these icons.
class Display {
public:
Display(const char ** _icons) : icons(_icons), current_icon(0) {}
void print_next_icon() {
std::cout << icons[++current_icon] << std::endl;
}
private:
const char **icons;
size_t current_icon;
}
I am getting a compiler error when I try to initialize the Display class by passing it the constexpr icons:
Display i1(icons1);
Display i2(icons2);
I've tried casting it to const char**, but the compiler complains that the cast removes attributes.
char**is not the same as achar [][40], so casting would have left you with a logic error.