Could someone tell me if my C++ indent style is named? (example given)
I'm learning C++. For me, my programming style is just what looks the best; it doesn't seem to follow the rules of any one particular style. Here's an example
void f(int x){ //no space between close-paren and bracket
if (!x开发者_如何转开发){
cout << "x is non-zero\n";
} //closing bracket indented to the same level as the original statement
}
It's only slightly different for something like a class or a namespace:
class myClass {}; //space between class name and bracket, otherwise the same as functions
K&R style does uses that kind of bracketing for statements, but my style uses it for everything. I'd like to know if there's a name for it so I can say simply what my indent style is without having to explain using examples like these.
I've never seen any code formatting guideline that recommends not including a space between )
and {
and to my eyes it looks very ugly.
Let's call it Maulrus style.
Looks BSD KNF style. see http://en.wikipedia.org/wiki/Indent_style
(note, it's also the same style I prefer :) )
It looks like a slight modification of K&R style; I'm not aware of any name for it. The potential variations on programming styles for a non-whitespace-sensitive language are so vast that you have to expect that few of them will have proper names.
精彩评论