zoukankan      html  css  js  c++  java
  • C++ mem_fun

     1 #include <stdio.h>
     2 #include <string>
     3 #include <iostream>
     4 #include <fstream>
     5 #include <iterator>
     6 #include <vector>
     7 #include <algorithm>
     8 #include <map>
     9 using namespace std;
    10 
    11 
    12 class Student
    13 {
    14 private:
    15     int sno;
    16 public:
    17     Student(int i)
    18     {
    19         sno=i;
    20     }
    21     int getSno()
    22     {
    23         return sno;
    24     }
    25     void printSno()
    26     {
    27         cout<<sno<<endl;
    28     }
    29     
    30 };
    31 vector<Student*> student_p;;
    32 void insertStudent(int& sno)
    33 {
    34     Student*sp=new Student(sno);
    35     student_p.push_back(sp);
    36 }
    37 
    38 int  main()
    39 {
    40     
    41     ifstream is("1");
    42 
    43     istream_iterator<int> ii(is);
    44     istream_iterator<int> eos;
    45 
    46     vector<int> v(ii,eos);
    47 
    48     for_each(v.begin(),v.end(),insertStudent);
    49     for_each(student_p.begin(),student_p.end(),mem_fun(&Student::printSno));
    50 
    51     return 0;
    52 }
  • 相关阅读:
    线段树套线段树
    hdu6800
    半平面交 poj1279
    Unity:创建了一个自定义的找子物体的脚本
    Unity:一个简单的开门动画
    hdu 4940
    hdu 4939
    hdu 4932
    hdu 4912
    AC自动机
  • 原文地址:https://www.cnblogs.com/mengqingzhong/p/3050156.html
Copyright © 2011-2022 走看看