#define with space(#用空格定义)
问题描述
是否可以用空格编写define,例如:
Is it possible to write define with spaces such as:
#define replace to replacement here
我想将replace to"替换为replacement here".
我想测试私有成员:
我确实写过
#define private public
但它不适用于 Qt 中的私有插槽
but it didn't work for private slots in Qt
所以我打算使用类似的东西
so my intend was to use something like
#define private slots: public slots:
无论如何,我找到了另一种测试插槽的方法,顺便说一下,我知道这是一个丑陋的 hack.
anyway I have found another way to test slots and by the way I'm aware of that this is an ugly hack.
推荐答案
不,你不能
#define identifier something
你定义的必须是一个不能包含空格的标识符.也不能包含连字符、以数字开头等,只能定义标识符
what you define must be an identifier which cannot contain space. Nor can it contain hyphen, begin with a number, etc. you can define only an identifier
你写的会起作用
#define replace to replace here
但不是你所期望的.这一行定义了 replace 被替换为 to replacement here
but not as you expect. This line defined replace to be substituted with to replacement here
这篇关于#用空格定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:#用空格定义
基础教程推荐
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 常量变量在标题中不起作用 2021-01-01
