Код: Выделить всё
#include
#include
#include
using bar = struct bar
{
int x;
char y;
};
auto main() -> int
{
std::array foo;
bar myBar [3] = { { 1, 'a'}, { 2, 'b'}, {3, 'c'} };
// Compiler error "Invalid array assigment" - comment it to get an executable file.
foo [0] = myBar;
// This works and foo [0] has also the correct content
memcpy( foo [0], myBar, sizeof(myBar) );
for ( auto const & fooBar : foo [0] ) {
printf( "x=%d - y=%c\n", fooBar.x, fooBar.y );
}
return 0;
}
https://onlinegdb.com/fdmywcfnus
Подробнее здесь: https://stackoverflow.com/questions/797 ... assignment