I scrolled up and realized that I pressed space bar in place of enter button.
okay it's
1 2 3 4 5
|
void function(parameters)
{ Statement1;
Statement2;
Statement3;
}
|
and not
1 2 3 4
|
void function(parameters)
{ Statement1;
Statement2;
Statement3; }
|
suppa wrote: |
---|
To me i said to keep cin and cout on two separate lines because for me it is easier to follow it. |
Oh! so you were asking smackthat1 to put cin and cout in separate lines so that it's easier for you to go through.
suppa wrote: |
---|
And for future refrence make your code neater. The cout and cin should be on seperate lines so its easier to follow through. |
After reading this I thought you were suggesting him to put cin and cout in separate lines for more clarity, so I pointed that out as I feel his program is already neat and clean.
doug4 wrote: |
---|
I think you are mistaken. I don't think most people prefer it this way.
I strongly disagree that "most of the people prefer it this way". |
I am not claiming that everyone do it this way but still I think that most people prefer it 'this' way as
1. I posted it on 25th and I am getting reply of denial on 30th.
2. I can't just drop this thought as many people around me do it the same way as I mentioned.
And I personally avoid
because I don't see any point in placing the braces after parenthesis, as I feel both the opening and closing brackets/braces/parentheses should be indented equally.
doug4 wrote: |
---|
I will always split this into 4 lines (the 1st religious war option). I have seen 1-liners, but corporate coding standards that I have worked with generally discourage it. |
Do you really mean always........ seriously, also when you overload functions like this.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
void print(int x)
{
cout<<x;
}
void print(int x, int y)
{
cout<<x+y;
}
void print(int x, float y)
{
cout<<x<<"≈"<<y;
}
void print(float x, float y)
{
cout<<x*y;
}
|
You mean you do like this...... well then this one was comical.
I find this way it's less chaotic than that one.
1 2 3 4 5 6 7
|
void print(int x) {cout<<x;}
void print(int x, int y) {cout<<x+y;}
void print(int x, float y) {cout<<x<<"≈"<<y;}
void print(float x, float y) {cout<<x*y;}
|
And honestly speaking, with those I worked, never came up with a negative attitude regarding this way.
doug4 wrote: |
---|
The important thing is clarity and consistency |
Define those words confining their meaning within creating a program and you'll contradict yourself yourself.
doug4 wrote: |
---|
I will weigh in on the cout/cin issue only to say I disagree with putting them on the same line. The arguments have been made by others. |
You just can't simply deny it. Many times I have seen it and so I started liking it even more.
Don't misunderstand me that I am forcing you to change your perspectives, I am not. No one is going to change his way of making programs just because most of the people don't do as he does.
But if he hasn't chosen any particular way, then which one he should choose, the discussion is about this only. So far the exact way is yet to be decided here. Deplorably can't create a poll :D