有人可以告诉我如何使用度数值,就像它是正常值一样吗? 例如:
#include <iostream>
#include <iomanip>
class hexa_s
{
mutable std::ostream *_out;
template<typename T>
const hexa_s& operator << (const T & data) const
{
*_out << std::internal << std::setfill( '0' ) << std::hex << std::showbase << std::setw( sizeof( T ) * 2 ) << data;
return *this;
}
friend const hexa_s& operator <<( std::ostream& out, const hexa_s& b )
{
b._out = &out;
return b;
}
};
hexa_s hexa( )
{
return hexa_s( );
}
int main()
{
int value = 4;
std::cout << hexa << value << std::endl;
return 0;
}
我希望y等于120.