Software Engineering project, Part II.5: C++ Whee~

Oct 25, 2006 16:23


[cb112@cslabpc4 ~]$ cat evaluationtest.cpp
#include
using namespace std;

int incrementAndReturn(int &i) {
return ++i;
}

int main(int argc, char *argv[]) {
int i = 0;
cout << incrementAndReturn(i);
cout << incrementAndReturn(i);
cout << incrementAndReturn(i) << endl;

i = 0;
cout << incrementAndReturn(i)
<< incrementAndReturn(i)
<< incrementAndReturn(i) << endl;

return 0;
}
[cb112@cslabpc4 ~]$ g++ -o evaluationtest evaluationtest.cpp
[cb112@cslabpc4 ~]$ ./evaluationtest
123
321
[cb112@cslabpc4 ~]$Interesting.

[cb112@cslabpc4 ~]$ cat evaluationtest2.cpp
#include
using namespace std;

int main(int argc, char *argv[]) {
int i = 0;
cout << ++i;
cout << ++i;
cout << ++i << endl;

i = 0;
cout << ++i << ++i << ++i << endl;

return 0;
}
[cb112@cslabpc4 ~]$ g++ -o evaluationtest2 evaluationtest2.cpp
[cb112@cslabpc4 ~]$ ./evaluationtest2
123
333
[cb112@cslabpc4 ~]$
Interesting.
Previous post Next post
Up