#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++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 从 std::cin 读取密码 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01