Analyze the compiler errors that appear in the following program, and give the solution.
#include <iostream>using namespace std;//define a function template Template<class t>t max (t A, T b) { return (a>b)? A:b;} int main () { int x=2,y=6; Double x1=9.123,y1=12.6543; cout<< "to instantiate T as int:" <<max (x, y) <<endl; cout<< "to instantiate T as Double:" <<max (x1,y1) <<endl; return 0;}
#include <iostream> template<class t> t Max (t A, T B) { return (a>b) a:b; } int main () { int x=2,y=6; Double x1=9.123,y1=12.6543; std::cout<< "to instantiate T as int:" <<std::max (x, y) <<std::endl; std::cout<< "to instantiate T as Double:" <<std::max (x1,y1) <<std::endl; return 0; }
Operation Result:
Summary of Knowledge points:
Resolve Conflicts
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
16th Week Item three conflict brought about by-max