J
John Brawley
Please pardon a maybe very stupid question?
I've read and reread Bjarne Stroustrup on this, and I still don't "get it,"
so I wrote this to help me understand, and now I _really_ don't "get it."
Why, if one increments before, and the other after, do these snippets output
exactly the same?
#include <iostream>
int main() {
for(int i=0; i<10; i++)
std::cout<<i<<", ";
std::cout<<"\n";
for(int i=0;i<10;++i)
std::cout<<i<<", ";
std::cout<<"\n";
int b=7;
b++; std::cout<<b;
int c=7;
++c; std::cout<<"\n"<<c;
//????????? why? same outputs!
return 0;
}
_Same_output_.
What's the difference?
(I use these in a program, which doesn't crash....)
I've read and reread Bjarne Stroustrup on this, and I still don't "get it,"
so I wrote this to help me understand, and now I _really_ don't "get it."
Why, if one increments before, and the other after, do these snippets output
exactly the same?
#include <iostream>
int main() {
for(int i=0; i<10; i++)
std::cout<<i<<", ";
std::cout<<"\n";
for(int i=0;i<10;++i)
std::cout<<i<<", ";
std::cout<<"\n";
int b=7;
b++; std::cout<<b;
int c=7;
++c; std::cout<<"\n"<<c;
//????????? why? same outputs!
return 0;
}
_Same_output_.
What's the difference?
(I use these in a program, which doesn't crash....)