Is anyone else surprised?

Trent Shipley plug-devel@lists.PLUG.phoenix.az.us
Mon Jun 11 05:26:02 2001


//compile using 
// g++ -g -o thisProg thisProg.cc

#import <iostream>
#import <iomanip>

int main()
{
    cout << setw(9) 
         << setfill('0')
         << 1.234;

// outputs ^@^@^@^@1.234
// expected 00001.234
// due to an implicit cast of the float to a string
// on overloaded "<<"


// making the cast explicit

    cout << setw(9) 
         << setfill('0')
         << static_cast<char*>(1.234);

// outputs 00001.234
// half expected the cast to fail

 
  return 0;
}



---------------------------

Trent Shipley

Work:
(602) 522-7502
mailto:tshipley@symbio-tech.com
http://www.symbio-tech.com