/* * @topic T00297 Apr 11 -- overloaded operator<< demo * @brief The program demonstrates <tt>cout << object</tt> */ #include <iostream> #include "counter.h" int main() { // The following two lines are equivalent: std::cout << "Hello\n"; operator<<( std::cout, "Hello\n"); // We can define similar output for our own classes: Counter cnt; cnt.increment(); cnt.increment(); cnt.increment(); cnt.increment(); // We could get the value using member function: //std::cout << cnt.get_count(); // Or we can take advantage of the stream insert: std::cout << cnt << '\n'; return 0; }