CHAPTER9-33.cpp
上传用户:fjc899
上传日期:2007-07-03
资源大小:187k
文件大小:1k
源码类别:

STL

开发平台:

C/C++

  1. //文件名:CHAPTER9-33.cpp
  2. #include <set>
  3. #include <iostream>
  4. #if _MSC_VER > 1020   // if VC++ version is > 4.2
  5.    using namespace std;  // std c++ libs implemented in std
  6. #endif
  7. int main( )
  8. {
  9.    set <int, less<int> > s1;
  10.    set<int, less<int> >::key_compare kc1 = s1.key_comp( ) ;
  11.    bool result1 = kc1( 2, 3 ) ;
  12.    if( result1 == true )   
  13.    {
  14.       cout << "kc1( 2,3 ) returns value of true, "<< "where kc1 is the function object of s1."<< endl;
  15.    }
  16.    else   
  17.    {
  18.       cout << "kc1( 2,3 ) returns value of false "<< "where kc1 is the function object of s1." << endl;
  19.    }
  20.    set <int, greater<int> > s2;
  21.    set<int, greater<int> >::key_compare kc2 = s2.key_comp( ) ;
  22.    bool result2 = kc2( 2, 3 ) ;
  23.    if(result2 == true)   
  24.    {
  25.       cout << "kc2( 2,3 ) returns value of true, "<< "where kc2 is the function object of s2." << endl;
  26.    }
  27.    else   
  28.    {
  29.       cout << "kc2( 2,3 ) returns value of false, "<< "where kc2 is the function object of s2." << endl;
  30.    }
  31. }