-3

I have

struct vehicle {
  int available_supply=10;
  int is_assigned_to_route=1;
};

vehicle vehicle_info [2];

how to make a copy of vehicle_info?

i want something like

vehicle inital_vehicle_info [2]=vehicle_info;

could someone give me a hint, please?

1 Answers1

0

Arrays are not directly copyable — it does not matter what they are arrays of.

You can and should use a wrapper:

// Use std::array instead
std::array<vehicle, 2> vehicle_info;

// Now this is easy:
std::array<vehicle, 2> initial_vehicle_info = vehicle_info;
Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055