返回引用的函数值和参数的引用

#include <iostream>
using namespace std;
int &max1(int &num1,int &num2){
    return (num1>num2)?num1:num2;
}
int &min1(int &num1,int &num2){
    return (num1<num2)?num1:num2;
}
int main(){
    int num1,num2;
    cout<<"please input num1"<<endl;
    cin>>num1;
    cout<<"please input num2"<<endl;
    cin>>num2;
    max1(num1,num2)=0;
    cout<<"\n find the max ,and make the max to be 0, now the two num is:"<<endl;
    cout<<num1<<" "<<num2<<endl;

}

posted @ 2018-04-28 22:16  UnderScrutiny  阅读(206)  评论(0编辑  收藏  举报