C++ Class, Assigning values during Constructor initialization -
i have 2d array declared part of classes private members. when call constructor, start assigning values 2d array. every time so, i'm hit error c2059. make sure nothing else causing error commented out line , compiler finished putting binary file.
tried: variable[row] = { 0, 1, 2, 3}; variable[row][] = { 0, 1, 2, 3}; variable[row][4] = { 0, 1, 2, 3};
no luck, clues. in advance.
unfortunately, can't yet initialize arrays members of classes. don't know how yours declared, here's example of do:
class x { int variable[3][4]; public: x() { const int temp[][4] = { { 1, 2, 3, 4}, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; const int sz = sizeof(variable)/sizeof(**variable); std::copy(*temp, (*temp) + sz, *variable); } };
Comments
Post a Comment