C ++中的函数名称:大小写与否? [英] Function names in C++: Capitalize or not?
问题描述
在C ++中命名函数的惯例是什么?
我来自于java环境,所以我通常命名为:
myFunction(...){
}
我见过C ++中的混合代码,
myFunction(....)
MyFunction (....)
Myfunction(....)
?
此外,类函数和不是类函数的函数是否相同?
没有一个正确的方法。它们在语法上都是正确的,虽然有一些约定。您可以按照 Google风格指南。
p>正则函数有混合情况;访问器和变量符匹配变量的名称:MyExcitingFunction(),MyExcitingMethod(),my_exciting_member_variable(),set_my_exciting_member_variable()。
What's the convention for naming functions in C++?
I come from the java environment so I usually name something like:
myFunction(...){
}
I've seen mixed code in C++,
myFunction(....)
MyFunction(....)
Myfunction(....)
what's the correct way?
Also, is it the same for a class function and for a function that's not a class function?
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.
From said guide:
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屋!