Page 1 of 1

Posted: Sat Mar 26, 2005 3:12 pm
by Guest
I am just learning C++. In 18 days (I'm reading Teach Yourself C++ in 21 Days, I'm on #4) I think I might attempt to learn SDL.

JS Lemming, why do you use that style? Isn't it just more typing? I honestly don't see a reason to do that is you could achieve the same thing without the {}'s.

Code: Select all

void SetLife(int value) 
{ 
   life = value; 
   if(life > maxlife) { life = maxlife; } 
} 
I would write as:

Code: Select all

void setLife(int value) {
     life = value;
   
     if (life>maxlife)
          life = maxlife;
}
I dunno, I guess it's just a matter of person taste. According to Jesse Liberty, the best way to start a religious war is to ask two programmers the best style to program with.

The dude in the book I'm reading programs kinda like you, JS Lemming. lol

Posted: Sat Mar 26, 2005 3:14 pm
by Guest
Yeah, I know these people in real life and they're learning to dev for the PC. None of them will squeal because I know where they live.
You don't know where I live. And if you ever find out, I'll kill your whole family! MUHAHAHAHAH! :twisted:

Posted: Sat Mar 26, 2005 4:28 pm
by JS Lemming
I just use that style cause a lot of times I have about 50 if statements embedded into each other. Without the brackets I would easly loose which if is in another if.