Код: Выделить всё
struct Foo {
int x, y;
Foo(int X, int Y) : x(X), y(Y) {}
Foo(const Foo& f) : Foo(f.x, f.y) {}
};
Foo foo1(1, 2);
Foo foo2 = Foo(foo1);
Код: Выделить всё
struct Foo {
int x, y;
Foo(int X, int Y) : x(X), y(Y) {}
// Foo(const Foo& f) : Foo(f.x, f.y) {}
Подробнее здесь: [url]https://stackoverflow.com/questions/78658079/c-struct-initialization-using-own-type[/url]