Visual C 中的新关键字和新指针类型; 2005. 什么是托管 C++?

发布于 2024-08-07 16:29:14 字数 667 浏览 12 评论 0原文

可能的重复
什么是 gcnew?
插入符号在 C++/CLI 中意味着什么?
托管 C++ 和 C++ 之间的差异

我是一名使用 g++ 的高级 C++ 程序员。但目前我正在使用 Visual C++ 2005 进行 Windows 窗体应用程序编程。但我发现它的新术语很难理解。例如,它不是 new 它有 gcnew

String ^ 之类的东西。有人可以解释一下什么是^,类似于指针吗?

我能让 Visual C++ 以与普通 C++(如 g++ 编译器)相同的方式工作吗?我还听说过一些有关托管 C++ 的事情。那是什么?

Possible duplicates
What is gcnew?
What does the caret mean in C++/CLI?
Difference between managed c++ and c++

I am a advanced C++ programmer with g++. But currently I am working on Visual C++ 2005 doing Windows Forms Application programming . But I am finding it hard with its new terminology. For e.g. instead of new it has gcnew and

String ^ kind of thing. Can someone explain what is ^, similar to pointer?

Can I make Visual C++ work in the same way as normal C++ like g++ compiler? I also heard something about managed C++. What is that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

若无相欠,怎会相见 2024-08-14 16:29:14

gcnew 和 ^ 值由 C++ 托管,C++ 是与 C++ 不同的语言。您可以将 VS2005 用作普通的 C++ 编译器,只需不使用新项目窗口的 CLR 部分中的项目类型即可。

The gcnew and ^ values are managed C++ which is a different language to c++. You can use VS2005 as a normal C++ compiler by not using a project type from the CLR section of the new project window.

鹿童谣 2024-08-14 16:29:14

gcnew^ 来自新的 Visual C++ 语法。新语法不是 ISO/ANSI C++ 标准的一部分,而是一组根据 Ecma C++/CLI 标准标准化的 C++ 扩展。如果您不愿意,您可以不使用它们。 在这里您可以了解有关 Visual C++ 的更多信息扩展。

gcnew and ^ are from new Visual C++ syntax. The new syntax is not part of the ISO/ANSI C++ standard, but is a set of extensions to C++ standardized under the Ecma C++/CLI Standard. You can to not use them if you do not want to. Here you could read more about Visual C++ extensions.

神爱温柔 2024-08-14 16:29:14

Windows 窗体是 .Net 特定的,因此如果您想执行这些操作,则需要使用 C++/CLI(即“托管 C++”)。

不过,我不确定你真的想要 Windows 窗体吗?您只是想要某种窗口 GUI,对吧?如果是这种情况,您可以使用 MFC 或本机操作系统调用之类的东西来创建 GUI,或者您可以使用包装 API,例如 Qt

[编辑] 只是为了澄清一下:)

我还听说过一些有关托管 C++ 的事情。那是什么?

C++/CLI 是 C++ 的 .Net 实现。在这里您可以使用常规 C++ 和托管代码。 C++/CLI 是 Microsoft 试图简化 C++ 开发人员进入托管框架的学习曲线的尝试,但是,现在它的使用并不多,您可能很难找到任何好的教程。 Visual C++只是IDE的名称,与你使用哪种C++无关。您可以像使用 g++ 一样使用 Visual C++,但如果您不需要控制台应用程序上的任何内容,则需要将一些 GUI 逻辑连接到您的应用程序中。正如我在最初的回答中所说,这可以通过多种方式完成。

如果你确定你想使用.Net,我建议你花一天时间学习 C#,因为如果你有 C++ 经验,学习它真的很容易,但从你的问题来看,我认为这不是你想要的:)

Windows Forms are .Net specific, so you need to use C++/CLI (That's "managed C++") if you want to do those.

However, I'm not sure you really want windows forms? You just want some kind of windowy GUI, right? If that's the case you can go with something like MFC or just native O/S calls, to create your GUI, or you could use a wrapper API like Qt

[EDIT] Just to clarify a bit :)

I also heard something about managed C++. What is that?

C++/CLI is the .Net implementation of C++. Here you can use both regular C++ and managed code. C++/CLI was Microsofts attempt to ease the learning curve for C++ developers to get into the managed framework, however, it's not used a lot these days, wo you'll probably have a hard time finding (m)any good tutorials. Visual C++ is just the name of the IDE, it has nothing to do with which kind of C++ you use. You can use Visual C++ just as you use g++, but if you wan't anything over a console app, you'll need to wire some GUI logic into your application. As said in my original answer, this can be done a number of ways.

If you are sure you want to use .Net, I recommend spending a day with C#, as it's really easy to learn if you got C++ experience, but judging from your question I don't think this is what you want :)

浊酒尽余欢 2024-08-14 16:29:14

托管 C++ 用于 Microsoft 公共语言运行时 (CLR) 中的 .Net 开发。创建这种特殊的 C++ 语法是为了让 C++ 开发人员无需学习 C# 等新语言即可进入 .Net 社区。

您可以通过创建非 CLR 项目以与 g++ 相同的方式使用 Visual C++。

Managed C++ is used for .Net development in the Common Language Runtime (CLR) of Microsoft. This special C++ syntax was created to allow C++ developper to come in the .Net community without learning a new language like C#.

You can use Visual C++ in the same way as g++ by creating a non-CLR project.

青朷 2024-08-14 16:29:14

请注意,Windows 窗体并不是在 Windows 下制作 GUI 的唯一方法。如果您想要纯 C(如果您愿意,可以用 C++ 包装),您可以使用常规 Win32 API。

如果您选择 Windows 窗体,则可以选择使用 C#、VB.NET 或 C++/CLI(托管 C++)。您不需要使用 C++/CLI,这似乎是您的假设。

Note that Windows Forms are not the only way to make GUIs under Windows. You can use the regular Win32 API instead, if you want pure C (which you can wrap with C++ if you like).

If you do choose Windows Forms, then you have the option of using C#, VB.NET, or C++/CLI (Managed C++). You need not use C++/CLI, as seems to be your presumption.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文