📜  函数模板 c++ 代码示例

📅  最后修改于: 2022-03-11 14:44:50.331000             🧑  作者: Mango

代码示例2
// function template in c++
#include 
using namespace std;
float funAvg(int a, int b){
    float avg = (a+b)/2.0;
    return avg;
}
float funAvg2(int a, float b){
    float avg2 = (a+b)/2.0;
    return avg2;
}

//function template in c++

template
float fun(T1 a, T2 b){
    float avg2 = (a+b)/2.0;
    return avg2;
}

int main(){
 
    float a;
    a = funAvg(22 , 7);
    printf("The average of these number is %.3f ",a);
    cout<