C++带有命令的 VBA 版本,用于更优雅的代码
C++ version of VBA's with command for more elegant code
我是用c++写的:
returner.token[0].type = "a";
returner.token[0].fQF = "b";
returner.token[0].val = "c";
returner.token[0].pos = "d";
returner.token[0].emit = "e";
在VBA中,你可以这样写:
with returner.token[0]
.type = "a"
.fQf = "b"
.val = "c"
.pos = "d"
.emit = "e"
end with
c++中是否有类似的功能?谢谢!
你在找参考资料。
auto& r = returner.token[0];
r.type = "a";
r.fQF = "b";
r.val = "c";
r.pos = "d";
r.emit = "e";
其他可以帮助您的机制包括定义适当的构造函数,并使用大括号初始化列表(如果合适)。
没有像Visual Basic with
那样的c++语句:它只是没有必要,引用可以减少歧义。
相关文章:
- 为什么模数运算符不适用于该代码
- FLTK 2.0构建和演示,适用于VS2019的2011年左右的代码库
- 以下 C++ 代码用于 -> "#define idiv(a, b) (((a) + (b) / 2) / (b))" 是什么?
- 用于将C++代码转换为 Web 程序集的脚本未终止
- 通过Python Distutils(用于Python C扩展)使用可重定位的设备代码编译CUDA代码
- 将 SFML 用于代码块C++出现错误库 SFML
- 用于查找数组中最大元素的出现次数的代码,给出分段错误
- 如何知道用于实现标准代码段的确切数据结构和算法,例如在C++STL中?
- Windows Toast 通知不适用于 MS CPP 示例代码
- 用于C++代码的 API 监视器类型定义 (XML)
- 未知 使用用于C++代码的标头编译 C 代码时char16_t未知类型名称
- 是否可以在不使用汇编的情况下告诉clang哪些寄存器用于代码的某些部分
- 如何在 CLANG 中创建用于代码完成的虚拟文件
- 枚举不适用于代码等模板
- 用于代码完成的 Geany c++ 标记文件
- 在 debian 中安装 boost(用于代码块)
- Xcode 7.2 和 Instruments 内存泄漏不适用于 C++ 代码
- 基于标记调度的专用化,用于C++代码中的平台识别和仿真
- TXL可以用于代码克隆检测
- 安装MinGW的gdb.exe用于代码块