Mail Archives: djgpp/2003/08/26/14:06:47
I'd be very grateful if anyone could tell me what's wrong with the
following code.
The line "os.setf( oldflags, ios::basefield);"
gives 2 compilation errors:
"invalid conversion from 'long int' to 'std::_Ios_Fmtflags'"
&
"initializing argument 1 of 'std::_Ios_Fmtflags
std::ios_base::setf(std::_Ios_Fmtflags,std::_Ios_Fmtflags)"
/*
* friend output operator
* Parameters:
* os - output stream to write to
* bigi - Big_int to print value of
* Return value:
* reference to os
*/
ostream & operator << ( ostream &os,
const Big_int & bigi )
{
long oldflags = os.setf( ios::hex, ios::basefield);
char old_fill = os.fill('0');
bool leading_zero = true;
for( int i = bigi.size_ - 1; i >= 0; i-- ) {
if ( ! leading_zero )
os.width(8);
if ( bigi.number_[i] != 0)
leading_zero = false;
else if (i != 0 && leading_zero)
continue;
os << bigi.number_[i];
}
os.fill(old_fill);
os.setf( oldflags, ios::basefield);
return os;
}
Mark Hinchcliffe
- Raw text -