Advertisement
spacechase0

Generic Log

Feb 24th, 2012
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. // GenericLog.h
  2. #include <fstream>
  3. #include <string>
  4.  
  5. class GenericLog
  6. {
  7.     public:
  8.         GenericLog( const std::string& filename = "log.txt" );
  9.        
  10.         template< typename T >
  11.         GenericLog& operator << ( const T& t )
  12.         {
  13.             std::cout << t;
  14.             file << t;
  15.            
  16.             return ( * this );
  17.         }
  18.    
  19.     private:
  20.         std::fstream file;
  21. };
  22.  
  23. // GenericLog.cpp
  24. GenericLog::GenericLog( const std::string& filename )
  25. {
  26.     // Create the file first :P
  27.     file.open( filename, std::fstream::out | std::fstream::app );
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement