我如何决定对新的

我如何决定对新的

本文介绍了我如何决定对新的 C++ 项目使用 ATL、MFC、Win32 还是 CLR?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始我的第一个 C++ 项目.我正在使用 Visual Studio 2008.它是一个单一形式的 Windows 应用程序,它访问几个数据库并启动一个 WebSphere MQ 事务.我基本上了解 ATL、MFC、Win32(实际上我对那个有点模糊)和 CLR 之间的区别,但我不知道应该如何选择.

I'm just starting my first C++ project. I'm using Visual Studio 2008. It's a single-form Windows application that accesses a couple of databases and initiates a WebSphere MQ transaction. I basically understand the differences among ATL, MFC, Win32 (I'm a little hazy on that one actually) and CLR, but I'm at a loss as to how I should choose.

其中一个或多个是否只是为了向后兼容?

Is one or more of these just there for backward-compatibility?

CLR 一个坏主意吗?

感谢任何建议.

我为这个项目选择了 C++ 的原因是我没有在帖子中讨论,这不完全是技术性的.那么,假设 C++ 是唯一/最好的选择,我应该选择哪个?

I've chosen C++ for this project for reasons I didn't go into in the post, which are not entirely technical. So, assuming C++ is the only/best option, which should I choose?

推荐答案

这取决于您的需求.

使用 CLR 将为您提供最具表现力的一组库(整个 .NET 框架),但代价是将您的可执行文件限制为要求在运行时安装 .NET 框架,以及限制您使用Windows 平台(不过,所有列出的 4 种技术都只是 Windows,因此平台限制可能是最不麻烦的).

Using the CLR will provide you with the most expressive set of libraries (the entire .NET framework), at the cost of restricting your executable to requiring the .NET framework to be installed at runtime, as well as limiting you to the Windows platform (however, all 4 listed technologies are windows only, so the platform limitation is probably the least troublesome).

但是,CLR 要求您使用 C++/CLI 对 C++ 语言的扩展,因此从本质上讲,您需要学习一些额外的语言功能才能使用它.这样做可以为您提供许多额外服务",例如访问 .net 库、完整的垃圾收集等.

However, CLR requires you to use the C++/CLI extensions to the C++ language, so you'll, in essense, need to learn some extra language features in order to use this. Doing so gives you many "extras," such as access to the .net libraries, full garbage collection, etc.

ATL &MFC 在两者之间做出决定有点棘手.我会向您推荐MSDN 页面进行选择以便在他们之间做出决定.ATL/MFC 的好处在于您不需要 .NET 框架,只需安装 VC/MFC 运行时即可进行部署.

ATL & MFC are somewhat trickier to decide between. I'd refer you to MSDN's page for choosing in order to decide between them. The nice thing about ATL/MFC is that you don't need the .NET framework, only the VC/MFC runtimes to be installed for deployment.

直接使用 Win32 提供最小的可执行文件,依赖最少,但编写工作量更大.您的辅助库数量最少,因此您需要编写更多代码.

Using Win32 directly provides the smallest executables, with the fewest dependencies, but is more work to write. You have the least amount of helper libraries, so you're writing more of the code.

这篇关于我如何决定对新的 C++ 项目使用 ATL、MFC、Win32 还是 CLR?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 14:29