Files
2023-07-08 09:36:10 -05:00

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;
}