123456789101112131415
#ifndef FOO_H #define FOO_H #include <iostream> class Foo { friend std::ostream& operator<<( std::ostream&, const Foo& ); public: Foo::Foo(); char* _item1; char* _item2; }; #endif
123456789101112
// foo.cpp #include "Foo.h" std::ostream& operator<< ( std::ostream& os = std::cout, const Foo& bar ) { os << bar._item1 << "\t" << bar._item2 << std::endl; return os; } Foo::Foo() : _item1( "item1" ), _item2( "item2" ) {}