How to modify a nested struct on a vector?

后端 未结 3 777
粉色の甜心
粉色の甜心 2021-01-29 10:20

I am working on a program that keeps inventory of vehicles, so I created a struct for it. It also needs to keep a list of the drivers, so I created a nested struct for that. Her

3条回答
  •  北海茫月
    2021-01-29 10:50

    How to modify a nested struct on a vector?

    To set the driver of the N-th item from the vector of Vehicles, you'd use:

    Vehicle::Driver driver_dude;
    ...
    ...
    vtnewV[N-1].dude = driver_dude;
    

提交回复
热议问题