C ++中允许以下构造的语法是什么,在 class和 class_name之间出现一个单词?
What is the syntax in C++ that allows the following construction, where a word appears in between "class" and "class_name"?
namespace octave { // Command line arguments. See also options-usage.h. class OCTINTERP_API cmdline_options { public: ...注意,我并不是在问宏的含义。我不是在问它做什么。我不是问它是否为空。我在问类定义的语法。
Note, I am not asking the meaning of the macro. I am not asking what it does. I am not asking if it is empty. I am asking about the syntax of class definition.
一些资料解释了语法,但是中间没有单词,例如:
Several sources explain the syntax, but without the word in the middle, for example:
class class_name { access_specifier_1: member1; access_specifier_2: member2; ... } object_names;还请注意以下有关语法的问题和答案与其他有关: 在c ++中的类定义前面的宏和 C ++类定义语法
Note also that the following questions asked about the syntax and the answers were about something else: macro in front of class definition in c++ and C++ Class definition syntax
推荐答案它不是标准的C ++(除非宏评估为空格,或者您使用的是属性),但是某些编译器在针对特定平台时需要使用它。
It's not standard C++ (unless the macro evaluates to whitespace, or you're using attributes) but it's required by some compilers when targeting certain platforms.
常见的情况是在为Windows构建动态链接库(dll)时。生成dll时, OCTINTERP_API 可能设置为 __ declspec(dllexport),而 __ declspec(dllimport )(使用dll时)。
A common occurrence is when building a dynamic linked library (dll) for Windows. OCTINTERP_API is likely set to __declspec(dllexport) when building the dll, and __declspec(dllimport) when using the dll.
(请参见 en.cppreference/w/cpp/language/classes )
更多推荐
C ++中类定义前面的宏是什么意思
发布评论