C++中的_In_是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11457328/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 15:09:48  来源:igfitidea点击:

What is _In_ in C++?

c++cmicrosoft-metroc++-cx

提问by Infinity James

I have searched this up rather a lot, but come up with no helpful results.

我已经搜索了很多,但没有找到有用的结果。

I am currently trying to program simple DirextX game for Windows 8 Metro, and have come across _In_rather a lot. I'm just wondering what it is.

我目前正在尝试为 Windows 8 Metro 编写简单的 DirextX 游戏,并且遇到_In_了很多。我只是想知道它是什么。

Also, I have seen a lot of the use of ^as the pointer *which I found odd. On top of this, some classes have an interface of ref class MyClass, which I believe is for C# legibility.

此外,我已经看到了很多我觉得奇怪^的指针的使用*。最重要的是,一些类有一个 的接口ref class MyClass,我认为这是为了 C# 的易读性。

Anyway, any help would be brilliant.

无论如何,任何帮助都会很棒。

回答by James McNellis

It is a SAL annotation, used for code analysis. The annotations themselves are defined as macros that, in normal builds, expand to nothing.

它是一个SAL 注释,用于代码分析。注释本身被定义为宏,在正常构建中,这些宏不会扩展到任何内容。

The ^and ref classare features of C++/CX, a set of language extensions developed to make it easier to build Metro style apps for Windows 8 in C++. Neither is a part of standard C++. The documentation (linked previously) has links to tutorials and references describing the language extensions.

^ref class有特色C ++ / CX,集开发,使其更容易打造下的Windows 8 Metro风格应用++语言扩展。两者都不是标准 C++ 的一部分。文档(先前链接)包含指向描述语言扩展的教程和参考资料的链接。

回答by Max

I think (from a quick google) that the _in_is there to indicate if a parameter is an input or output (_out_) to a function/method.

我认为(从一个快速的谷歌)_in_那里表明一个参数是_out_一个函数/方法的输入还是输出()。

The ^is a managed pointer (garbage collected pointer, related to C++/CLI).

^是一个托管指针(垃圾收集指针,与C ++ / CLI)。

回答by Diptendu

_Out_means argument passed as reference. _In_means the opposite. (_Out_ x)and (&x)are similar.

_Out_表示作为参考传递的参数。_In_意思相反。(_Out_ x)并且(&x)是相似的。