如何知道一个函数是属于.NET还是C ++?

时间:2017-06-15 09:18:45

标签: .net c++-cli

我目前在Visual Studio上使用.NET C ++。

我知道.NET和C ++之间的区别:在这种情况下,C ++是一种编程语言,.NET是基于C ++的框架。如果我错了,请纠正我。

但有时我会在这里问一些问题,用户问我是不是在谈论.NET函数或C ++函数。我认为某些C ++的函数被.NET覆盖,但我不清楚如何区分一个函数是否属于C ++或.NET。

也许这是一个非常简单的问题,但我对此并不确定。

2 个答案:

答案 0 :(得分:2)

Read the docs as a first step (and usually the last). In visual studio, at least, you can just hit F1 to bring that up in a browser. That said, if the function takes or returns any managed references (eg. ones with a ^) or if the class must be allocated with gcnew it is .net.

Regarding the specific issue from your last question (it was slightly whether an array<> was managed or unmanaged), the major issue was simply that your question lacked the C++-CLI tag, so the answerers were not immediately aware of the language you were using and assumed C++, as you did have that tag.

The specific issue of array is partially because you can use it in C++-CLI without having to add a using namespace or a cli:: namespace qualification. Thankfully, the cli namespace only contains 4 things and is the only one to be imported implicitly into a C++-CLI project. Everything else in .net is part of a managed namespace (I believe), and it should be obvious which bits of functionality you're pulling in from those.

答案 1 :(得分:0)

  

...并且用户问我是否在谈论.NET功能或C ++功能。

我想在这种情况下用户想知道的是你是在谈论托管类还是C ++ / CLI实现中的非托管类。实际上,您可以在C ++ / CLI中声明两种类型:托管类型,声明为&#34; ref class&#34; (有时也称为包装类),或简单的本机非托管类型,简称为&#34; class&#34;。

主要区别在于你可以在&#34; ref class&#34;中使用所有.NET类,而普通&#34;类&#34;就像一个普通的C ++类。而且,&#34; ref class&#34;有很多语法扩展需要连接.NET框架,本地&#34;类&#34;缺乏。