ukula 发表于 2017-12-9 13:56:00

c++ 引用类型以及函数指针

#include "stdafx.h"
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
using namespace std;
typedef int& ex(int &, int &);
int& exchange(int &, int &);
void acb(ex,int &,int &);

int main() {
   int a = 123,b = 999;
   acb(exchange, a, b);
   cout << a << "   " << b << endl;
   system("pause");
}

void acb(ex e,int &a,int &b) {
   cout << e << endl;
   ex *exx = e;
   exx(a, b) = 998;
   //cout << exx(a, b) << endl;
}

int& exchange(int &a, int &b) {
   int temp;
   temp = a;
   a = b;
   b = temp;
   double c = 1.3;
   return b;
}
页: [1]
查看完整版本: c++ 引用类型以及函数指针