Original Post
Hello, Out of boredom I decided to make an attempt to code a flexible integer class for fun and learning purposes. One function that I was thinking of raise my concern. I'll show you the source :
class cInteger
{
int _i ;
public :
cInteger() _i(0) { }
cInteger( int const& p_i ) : _i(0) { }
cInteger operator<<( ostream& o )
{ // Evidently this isn't flexible at all.
o << _i ;
return (*this) ;
}
} ;
ofstream f( "Example.txt" ) ;
cInteger a( 9 ) ;
// These work fine.
a << cout ;
a << fout ;
// What I'm trying to do is compound the two parameters like so :
a << cout << fout ; // It outputs to the screen successfully but doesn't output to file.
// My other problem is how I would make my class-method more flexible by having it accept
// a new line, '\n' or endl
// Any suggestions?