Arduino 相当于 VB WITH
Arduino equivalent to VB WITH
是否有与 Visual BASIC "with" 概念等效的 Arduino?
如果我有 Arduino 结构如下:
typedef struct {
int present = 0; // position now
int demand = 0; // required position
} superStruct;
superStruct super;
我可以说
if (super.present > super.demand) { super.present-=1; }
有什么方法可以缩短为
with super {
if (.present > .demand) { .present-=1; }
}
谢谢!
C++ 中没有等效的语法;您必须指定 struct
实例和成员。
只是为了补充 John Bode 的回答:请注意结构的方法¹
可以访问没有前缀的成员:
struct superStruct {
int present = 0; // position now
int demand = 0; // required position
void update_position() {
if (present > demand) { present-=1; }
}
};
superStruct super;
super.update_position();
¹C++ 中的结构只是一个 class,默认情况下所有成员 public。
是否有与 Visual BASIC "with" 概念等效的 Arduino?
如果我有 Arduino 结构如下:
typedef struct {
int present = 0; // position now
int demand = 0; // required position
} superStruct;
superStruct super;
我可以说
if (super.present > super.demand) { super.present-=1; }
有什么方法可以缩短为
with super {
if (.present > .demand) { .present-=1; }
}
谢谢!
C++ 中没有等效的语法;您必须指定 struct
实例和成员。
只是为了补充 John Bode 的回答:请注意结构的方法¹ 可以访问没有前缀的成员:
struct superStruct {
int present = 0; // position now
int demand = 0; // required position
void update_position() {
if (present > demand) { present-=1; }
}
};
superStruct super;
super.update_position();
¹C++ 中的结构只是一个 class,默认情况下所有成员 public。