共用方式為


showbase

Indicates the notational base in which a number is displayed.

ios_base& showbase( 
   ios_base& _Str 
);

Parameters

  • _Str
    A reference to an object of type ios_base, or to a type that inherits from ios_base.

Return Value

A reference to the object from which _Str is derived.

Remarks

The notational base of a number can be changed with dec, oct, or hex.

The manipulator effectively calls _Str.setf(ios_base::showbase), and then returns _Str.

Example

// ios_showbase.cpp
// compile with: /EHsc
#include <iostream>

int main( ) 
{
   using namespace std;
   int j = 100;

   cout << showbase << j << endl;   // dec is default
   cout << hex << j << showbase << endl;
   cout << oct << j << showbase << endl;

   cout << dec << j << noshowbase << endl;
   cout << hex << j << noshowbase << endl;
   cout << oct << j << noshowbase << endl;
}
100
0x64
0144
100
64
144

Requirements

Header: <ios>

Namespace: std

See Also

Reference

iostream Programming

iostreams Conventions