#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++ 迭代器有什么问题? 2022-01-01
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- 初始化列表*参数*评估顺序 2021-01-01
- CString 到 char* 2021-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
