
There has been some questions posed to me as to the difference between Jonathan's iostreams library filter concept ( http://home.comcast.net/~jturkanis/iostreams/libs/iostreams/doc/ ). The iostreams library and it is the correct choice if you are writing a relatively simple filter, but writing an even more sophisticated program as an iostreams filter, is non-trivial. For instance the following code would require some significant rewriting in order to make it a single filter object. public Avg : Program { virtual void Main() { double dSum = 0; int nCnt = 0; while (!cin.eof()) { double d; std::cin >> d; dSum += d; } std::cout << dSum << std::endl; } } This is primarily because a filter involves a series of calls to a single function such as put or get (see: http://home.comcast.net/~jturkanis/iostreams/libs/iostreams/doc/tutorial.htm... ) . The point of the Program class is that I want to be able to write a C++ programs as naturally as possible, and still redirect it, or chain them together simply. The above program can be redirected to a stream, or to another file by simply writing: Avg() > fstream("c:\\tmp.txt"); Just so I am clear. I am not at all suggesting that what I propose is replacement for any part of the iostream library. It is designed as an alternative to using main(). Christopher Diggins http://www.cdiggins.com http://www.heron-language.com
participants (1)
-
christopher diggins