I have a class such as:
class dialog
{
public:
double dReturnType[][5][3];
};
#include <cstdlib>
#include <iostream>
include <string>
using namespace std;
#include "dialog.h";
int main(int argc, char *argv[])
{
dialog People;
People.dReturnType[0][1] = {1.2,2.3,6.6};
return 0;
}
It returns:
[Warning] extended initializer lists only available with -std=c++11 or -std=gnu11 [enabled by default] [Error]: assigning to an array from an initializer list
I've looked it up online a bit and really couldn't find a way to get around this. I'd prefer not editing the class within it's on class file (kinda defeats the purpose). Any help?
Note: the class is in a separate project file
Initializer lists are just usable during initialization.
If you want use std::initializer_list
after initialization:
auto init = std::initializer_list<double>({1.2,2.3,6.6});
std::copy(init.begin(), init.end(), your_array);