Win32 / MFC与C ++的命名约定 [英] Naming convention for Win32/MFC with C++

查看:106
本文介绍了Win32 / MFC与C ++的命名约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio 2010使用Win32 / MFC框架和C ++编程语言的应用程序。

I am working on an application which uses Win32/MFC framework and C++ programming language using Visual Studio 2010.

我的问题是哪个命名约定需要使用变量,函数名,类名等。我听说Microsoft建议使用匈牙利记法命名约定。

My question is which naming convention needs to use for variables, function name, class name and etc. I heard Microsoft suggest to use "Hungarian notation" naming convention.

请让我知道使用哪种标准?

Can you please let me know which standard to use?

推荐答案

可能有一个真正好的理由,希望您的代码看起来熟悉的其他程序员谁学习MFC。如果是这样,那么您可以模仿 MFC样例和教程,并做他们做的...

You might have a truly good reason to want your code to look familiar to other programmers who have learned MFC. If so, then you could emulate the conventions of the MFC Samples and Tutorials, and do what they do...

但是MFC是一个早期起源的旧库,并且时代已经改变。 Microsoft的样式指南现在特别说使用匈牙利语符号:

But MFC is a legacy library which originated very early, and times have changed. Microsoft's style guidelines now specifically say NOT to use Hungarian notation:

http://msdn.microsoft.com/en-us/library/ms229042.aspx

这一边,而不是盲目地跟随任何特定文档,最好评估每个单独的约定。例如,当MFC样本创建类并有成员变量时,它们以 m _ 开头。 StackOverflow有关于这个特定想法的问题,你可以阅读替代方法:

That aside, rather than blindly following any particular document, it is probably better to evaluate each individual convention. For instance, when MFC samples make classes and have member variables, they start the name with m_. StackOverflow has questions about this particular idea and you can read about alternatives:

Why use prefixes on member variables in C++ classes

我更倾向于使用Qt的API风格指南,其大部分惯例适用于我:

I'm more aligned with Qt's API Style Guidelines, and most of their conventions work for me:

http://doc.qt.nokia.com/qq/qq13-apis.html

说到这一点,Qt是一个很好的C ++产品不断发展和成熟。将MFC从水中(完全)吹除并且是跨平台的...

Speaking of which, Qt is a nice C++ offering that has continued to evolve and mature. Blows MFC out of the water (completely) AND is cross-platform...

http://qt.nokia.com/products/developer-tools/

如果要锁定在Microsoft Universe中去.NET和C#。这将是一个步骤,你不会被困在MFC放弃。

If you want to be locked in the Microsoft universe go for .NET and C#. That would be a step up, and you wouldn't be stuck with the MFC abandonware.

这篇关于Win32 / MFC与C ++的命名约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆