chapter10-36.cpp

来自「C++STL程序员开发指南」· C++ 代码 · 共 32 行

CPP
32
字号
//文件名:CHAPTER10-36.cpp
#include <map>
#include <iostream>
#if _MSC_VER > 1020   // if VC++ version is > 4.2
   using namespace std;  // std c++ libs implemented in std
#endif
void main( )
{
   multimap <int, int, less<int> > m1;
   multimap <int, int, less<int> >::key_compare kc1 = m1.key_comp( ) ;
   bool result1 = kc1( 2, 3 ) ;
   if( result1 == true )   
   {      cout << "kc1( 2,3 ) returns value of true, "
           << "where kc1 is the function object of m1."<< endl;
   }
   else   
   {      cout << "kc1( 2,3 ) returns value of false "
           << "where kc1 is the function object of m1."<< endl;
   }
   multimap <int, int, greater<int> > m2;
   multimap <int, int, greater<int> >::key_compare kc2 = m2.key_comp( );
   bool result2 = kc2( 2, 3 ) ;
   if( result2 == true )   
   {      cout << "kc2( 2,3 ) returns value of true, "
           << "where kc2 is the function object of m2."<< endl;
   }
   else   
   {      cout << "kc2( 2,3 ) returns value of false, "
           << "where kc2 is the function object of m2."<< endl;
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?