当一个类声明显示有两个名称时,是什么意思? [英] What does it mean when a class declaration appears to have two names?
问题描述
我想了解一些具有以下类语法的C ++代码:
I'm trying to understand some C++ code which has the following class syntax:
class Q_MONKEY_EXPORT BasePlugin : public QObject
{
// some code comes here
};
我不明白语法 class Q_MONKEY_EXPORT BasePlugin
。对我来说,看起来像是有两个名字的类。这种语法在C ++中到底意味着什么?
I cannot understand the syntax class Q_MONKEY_EXPORT BasePlugin
. To me it looks like if there are two names for the class. What exactly does this kind of syntax mean in C++?
推荐答案
Q_MONKEY_EXPORT很可能是一个#define。有时需要定义类,例如当类位于库中并且需要在头文件包含在其他位置时导出。在这种情况下,define解析为 __ declspec(dllexport)
(确切的语法将取决于您使用的工具)。
Q_MONKEY_EXPORT is most likely a #define somewhere. Defines like that are sometimes required, for example when the class is in a library and needs to be exported when the header file is included from somewhere else. In that case, the define resolves to something like __declspec(dllexport)
(the exact syntax will depend on the tools you are using).
这篇关于当一个类声明显示有两个名称时,是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!