在c++编程中的,一个小问题

c++中定义一个函数,比较两个数的大小,形参分别使用指针和引用

比较大小干什么呢

函数参数形参范例:
指针(type *,type *)
引用 (type &, type &)


#include<stdio.h>

int comp(int i, int*p)
{
    if (i>*p) return i;
    if (i<*p) return *p;
    return 0; //一样大返回0 
}

int main()
{
    int m=1,n=2;
    int *p=&n;
    printf("谁大:%d\n",comp(m,p));
    printf("谁大:%d\n",comp(n,p));
    return 0;
}