Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
CHAPTER9-38.cpp
Package: c++stl程序员开发指南.rar [view]
Upload User: fjc899
Upload Date: 2007-07-03
Package Size: 187k
Code Size: 1k
Category:
STL
Development Platform:
C/C++
- //文件名:CHAPTER9-38.cpp
- #include <set>
- #include <iostream>
- #if _MSC_VER > 1020 // if VC++ version is > 4.2
- using namespace std; // std c++ libs implemented in std
- #endif
- int main( )
- {
- multiset <int>::allocator_type ms1_Alloc;
- multiset <int>::allocator_type ms2_Alloc;
- multiset <double>::allocator_type ms3_Alloc;
- multiset <int>::allocator_type ms4_Alloc;
- // The following lines declare objects that use the default allocator.
- multiset <int> ms1;
- multiset <int, allocator<int> > ms2;
- multiset <double, allocator<double> > ms3;
- cout << "The number of integers that can be allocated"
- << endl << "before free memory is exhausted: "<< ms2.max_size( ) << "." << endl;
- cout << "The number of doubles that can be allocated"
- << endl << "before free memory is exhausted: "<< ms3.max_size( ) << "." << endl;
- // The following lines create a multiset ms4 with the allocator of multiset ms1
- ms1_Alloc = ms1.get_allocator( );
- multiset <int> ms4( less<int>( ), ms1_Alloc );
- ms4_Alloc = ms4.get_allocator( );
- // Two allocators are interchangeable if storage allocated from each can be
- // deallocated with the other
- if( ms1_Alloc == ms4_Alloc )
- {
- cout << "Allocators are interchangeable." << endl;
- }
- else
- {
- cout << "Allocators are not interchangeable." << endl;
- }
- }