i dont recognize this: n(1), that probably should be n=1, and n+1 should be n+=1 or simply n++: when you write n+1 you dont update the value of n, that statement would just return 2 (since you intialized n as 1)
Well, actually, int n(1) is probably *slightly* faster then int n = 1. This is because when you do int n(1) will call the constructor with the value of 1, whereas int n = 1 calls the constructor with no arguments, and then will assign 1 to n.
Nay. The compiler does not actually generate any code to default construct an int (other than perhaps a sub of the stack pointer to allocate space).
The reason mastuh8's second code doesn't work is the last expression in the for loop:
n+1
This creates a temporary variable which is assigned the value of n, then the temporary is incremented by one, and finally since the value of the expression isn't used, the temporary is thrown away. Upshot: n is never itself incremented.