次の方法で共有


dec

Specifies that integer variables appear in base 10 notation.

ios_base& dec(
   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

By default, integer variables are displayed in base 10.

dec effectively calls _Str.setf(ios_base::dec, ios_base::basefield), and then returns _Str.

Example

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

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

   cout << i << endl;   // Default is base 10
   cout << hex << i << endl;   
   dec( cout );
   cout << i << endl;
   oct( cout );
   cout << i << endl;
   cout << dec << i << endl;
}

100
64
100
144
100

Requirements

Header: <ios>

Namespace: std

See Also

Concepts

<ios> Members

iostream Programming

iostreams Conventions