Compartilhar via


ios_base::xalloc

Specifies that a variable is part of the stream.

static int xalloc( );

Return Value

The static member function returns a stored static value, which it increments on each call.

Remarks

You can use the return value as a unique index argument when calling the member functions iword or pword.

Example

// ios_base_xalloc.cpp
// compile with: /EHsc
// Lets you store user-defined information.
// iword, jword, xalloc
#include <iostream>

int main( ) 
{
   using namespace std;
   
   static const int i = ios_base::xalloc();
   static const int j = ios_base::xalloc();
   cout.iword( i ) = 11;
   cin.iword( i ) = 13;
   cin.pword( j ) = "testing";
   cout << cout.iword( i ) << endl;
   cout << cin.iword( i ) << endl;
   cout << ( char * )cin.pword( j ) << endl;
}
11
13
testing

Requirements

Header: <ios>

Namespace: std

See Also

Reference

ios_base Class

iostream Programming

iostreams Conventions

Other Resources

ios_base Members