1#include <iostream>2 using namespacestd;3 //using a template function to calculate an expression4template<classType>5 type ABC (type A,type b,type c)6 {7 returna+b+C;8 }9 //evaluating an expression with reference parameter pointersTentemplate<classType> OneType ABC (Type *a,type *b,type *c) A { - return(*a) + (*B) + (*c); - the } - - intMain () - { + intA=1, b=2, c=3; -cout<<"a="<<a<<", b="<<b<<", c="<<c<<Endl; +cout<<"The result of evaluating an expression using a function template is: \ n"; ACOUT<<ABC (a,b,c) <<Endl; at floatf=4, d=0.6, e=2.3; -cout<<"f="<<f<<", d="<<d<<", e="<<e<<Endl; -cout<<"The result of evaluating an expression using a function template is: \ n"; -COUT<<ABC (f,d,e) <<Endl; - int*p2,*q2,*R2; -p2=&A; inq2=&b; -r2=&C; to +cout<<"*p2="<<*p2<<", *q2="<<*q2<<", *r2="<<*r2<<Endl; -cout<<"The result of evaluating an expression with a reference parameter pointer is:"<<Endl; theCOUT<<ABC (P2,Q2,R2) <<Endl; * return 0; $}
The program has two template functions, type ABC (type A,type b,type c), type ABC (type *a,type *b,type *c) two parameters are different;
The result of the Code debugging operation is:
In C + +, function templates template and function arguments are pointers and are used in combination with return values