문제

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.

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top