zoukankan      html  css  js  c++  java
  • C++回调函数

    回调函数定义:函数作为参数,而发起的函数调用过程称为回调函数。

    // _回调函数C++.cpp : 定义控制台应用程序的入口点。
    //

    #include "stdafx.h"
    #include"stdlib.h"
    #include <stdio.h>
    using namespace std;
    int myCmp(int a, int b)
    {
     if (a>b)
      return 1;
     else
      return 0;
    }

    void selectSort(int *p, int n, int(*myCmp)(int, int))
    {
     for (int i = 0; i<n - 1; i++)
     {
      for (int j = i + 1; j<n; j++)
      {
       if (myCmp(p[i], p[j]))
       {
        p[i] = p[i] ^ p[j];
        p[j] = p[i] ^ p[j];
        p[i] = p[i] ^ p[j];
       }
      }
     }
    }
    int _tmain(int argc, _TCHAR* argv[])
    {
     int a[10] = { 1, 2, 3, 4, 5, 0, 9, 8, 7, 6 };
     selectSort(a, 10, myCmp);
     for (int i = 0; i<10; i++)
      printf("%d ", a[i]);
     system("pause");
     return 0;
     return 0;
    }

  • 相关阅读:
    JDK+MyEclipse+Tomcat配置
    常用数据类型占内存字节数
    连连看核心算法
    gnuplot画图
    socket服务器的搭建-Mac
    AlertController提示框
    block-循环引用
    OC基础(21)
    OC基础(20)
    OC基础(19)
  • 原文地址:https://www.cnblogs.com/lhuan/p/5717824.html
Copyright © 2011-2022 走看看