mirror of
https://github.com/VictorEijkhout/TheArtOfHPC_vol3_cppf08programming.git
synced 2026-01-24 22:44:48 +09:00
34 lines
746 B
C++
34 lines
746 B
C++
/****************************************************************
|
|
****
|
|
**** This file belongs with the course
|
|
**** Introduction to Scientific Programming in C++/Fortran2003
|
|
**** copyright 2017/8 Victor Eijkhout eijkhout@tacc.utexas.edu
|
|
****
|
|
**** stream.cxx : simulate an integer stream
|
|
****
|
|
****************************************************************/
|
|
|
|
#include <iostream>
|
|
using std::cout;
|
|
|
|
//codesnippet integerstream
|
|
class Stream {
|
|
private:
|
|
int last_result{0};
|
|
public:
|
|
int next() {
|
|
return last_result++; };
|
|
};
|
|
|
|
int main() {
|
|
Stream ints;
|
|
cout << "Next: "
|
|
<< ints.next() << '\n';
|
|
cout << "Next: "
|
|
<< ints.next() << '\n';
|
|
cout << "Next: "
|
|
<< ints.next() << '\n';
|
|
//codesnippet end
|
|
return 0;
|
|
}
|