C ++中类定义前面的宏是什么意思

编程入门 行业动态 更新时间:2024-10-11 15:17:40
本文介绍了C ++中类定义前面的宏是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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 ++中类定义前面的宏是什么意思

本文发布于:2023-06-03 09:48:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/471170.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:定义

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!