C++ 结构体的定义

struct 结构体名称{ 
   数据类型 A; 
   数据类型 B; 
}结构体变量名;

相当于:

struct 结构体名称{ 
   数据类型 A; 
   数据类型 B; 
}; 
struct 结构体名称 结构体变量名;

这种方式既定义了结构体名称,同时声明了一个结构体变量名。在其它地方也可以通过struct 结构体来再次声明其它变量。

struct update{
    double ref_v = 0;
    double target_v = 49.50;
    int lane = 0;
  } update;

  struct collider{
    bool collision = false;
    double distance = 0;
    double closest_approach = 1000;
    double target_speed = 0;
  } collider;

猜你喜欢

转载自www.cnblogs.com/fuhang/p/8986329.html