C ++中的函数名称:大小写与否? [英] Function names in C++: Capitalize or not?

查看:1243
本文介绍了C ++中的函数名称:大小写与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在C ++中命名函数的惯例是什么?

What's the convention for naming functions in C++?

我来自于java环境,所以我通常命名为:

I come from the java environment so I usually name something like:

myFunction(...){
}

我见过C ++中的混合代码,

I've seen mixed code in C++,

myFunction(....)
MyFunction(....)
Myfunction(....)

此外,类函数和不是类函数的函数是否相同?

Also, is it the same for a class function and for a function that's not a class function?

推荐答案

没有一个正确的方法。它们在语法上都是正确的,虽然有一些约定。您可以按照 google风格指南,但还有其他的。

There isn't a 'correct way'. They're all syntactically correct, though there are some conventions. You could follow the google style guide, although there are others out there.

从所述指南:


常规函数有混合大小写;访问器和变量符匹配变量的名称:MyExcitingFunction(),MyExcitingMethod(),my_exciting_member_variable(),set_my_exciting_member_variable()。

Regular functions have mixed case; accessors and mutators match the name of the variable: MyExcitingFunction(), MyExcitingMethod(), my_exciting_member_variable(), set_my_exciting_member_variable().

这篇关于C ++中的函数名称:大小写与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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