How to initialize an array easily in the constructor? For example
class A
{
array<array<int, 2>, 2> m;
A(int m00, int m01, int m10, int m11)
: m {m00, m01, m10, m11} // ??? how to list here
{}
};
class A
{
std::array<std::array<int, 2>, 2> m;
A(int m00, int m01, int m10, int m11)
: m {{{m00, m01}, {m10, m11}}}
{}
};
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.