Doesn't it just hurt your eyes...

Pages: 12345
1
2
3
4
5
6
7
std::cout << "This is "
             "a multiline" //literal concatentation
          << "cout statement." << std::endl
          << "I like to have "
          << "the << line up "
          << "but then he endl "
          << "will be at the end" << std::endl;
Last edited on
um,lol?
closed account (Dy7SLyTq)
@L B: when do you use that?
When I have a lot to output to the console in test programs?
Yes, that hurts eyes:
1
2
3
4
5
int main(){
   std::cout << "O Hai Thar";

   return 0;
}


The reason is simple:
when you want to determine a block of code it's easier if opening/closing braces are on the same level. That way you just have a go up some lines and you got it, otherwise your eyes have to stray all over the code
@coder777, do you really think you need {}s to tell where a block is? Can you say that
1
2
3
4
int main()
    std::cout << "O Hai Thar";

    return 0;

is somehow unclear? Before you say that this will get confusing in a function of 100 loc and 10 levels of indentation, I'll remind you that if you have that sort of functions in your code, you ought to be punched.
hamsterman wrote:
Can you say that
[...]
is somehow unclear?
It's perfectly clear. No ugly astray opening brace can make a block where you don't expect it
No ugly astray opening brace can make a block where you don't expect it
I have no idea what you mean by that. Is it about the scenario where you delete the } but forget the {?
do you think java just really wanted to be different?
Narwhals aren't real. The government made them up to scare us into buying toilet paper.
closed account (Dy7SLyTq)
take that back! they are as real as tree octopodes
whats the connection between narwhals and toiletpaper? or am i just being slow?
You need to upgrade from Windows XP if you want to understand.
closed account (Dy7SLyTq)
ah is this a natty reference?
Because I first used C# for 2 years before starting with C++. I do things like so:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class MyClass  // classes, structs, enums all in upper case.
{
    private:
        int myInt; // lower case for private field.

    public:
        MyClass();
        ~MyClass();
        
        int MyInt;  // Upper case for public field.

        // Upper case for functions, which I use to refer them as methods in C#
        void MyFunction(); 
};

void MyClass::MyFunction()
{
    int a = 0;
    double b = 1.5;

    while (a < 10)   // single line, no braces.
          a++;

    while (b < 10)
    {
        b += 0.1;
        std::cout << b << std::endl;
    }
}

int main()
{
    MyClass myClass   // lower case for all variables.
    return 0;
}


Because in C# there are Interfaces, it was hard at first getting used to putting the class members stuff outside of the class. As in C# everything is inside the class braces. If you've never used C# I will not go in details here as it is beyond the scope of this thread. But feel free to look up C# interfaces on MSDN.

Enums, Structs, and so forth all following the same rules as above.
Last edited on
is this is a natty reference http://www.youtube.com/watch?v=3BfkuyeizNU
or do I really have to upgrade to know the difference between narwhals and toilet paper??


(I will know if you didn't listen to the whole thing cos you proly wont like it)
closed account (Dy7SLyTq)
i didnt listen to the whole thing. wrong natty btw i meant ubuntu 11.04 aka natty narwhal
I believe one-liners should live up to their name and actually be one line:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
if(condition)
    statement; //wrong!
    statement; //I'm a python coder and don't know better!

if(condition) statement; //better, one line

if(condition){
    statement; //kind of claustrophobic, but much better
    statement;
}

if(condition)
{
    statement; //ahh, much better
    statement;
}
Narwhals have nothing to do with toilet paper, I was just being ridiculous.
closed account (Dy7SLyTq)
i take it you dont like python syntax
Pages: 12345