L
laird
#include <iostream>
int main() {
int i = 1;
std::cout << i << i++ << i << "\n";
}
Compiling this code in g++ prints out 212 . Is this correct? If so, I don'tunderstand why.
Shouldn't this actually be equivalent to f(f(f(f(std::cout,i),i++),i),"\n")where f is operator<< ? In that case, each time a function is entered, there should be a sequence point which makes the side effects happen. So I'd expect the output to be 112 instead.
% g++ --version
g++ (Debian 4.6.1-4) 4.6.1
Best regards,
Laird Breyer
int main() {
int i = 1;
std::cout << i << i++ << i << "\n";
}
Compiling this code in g++ prints out 212 . Is this correct? If so, I don'tunderstand why.
Shouldn't this actually be equivalent to f(f(f(f(std::cout,i),i++),i),"\n")where f is operator<< ? In that case, each time a function is entered, there should be a sequence point which makes the side effects happen. So I'd expect the output to be 112 instead.
% g++ --version
g++ (Debian 4.6.1-4) 4.6.1
Best regards,
Laird Breyer