Menu

About Explicit Template Arguments

2003-01-23
2012-09-26
  • Nobody/Anonymous

    Help!!,I'm learning C++ function template,but
    What's wrong with the prog.
    #include<iostream>
    using namespace std;
    template<typename t> t min1(t a,t b){return a>b?b:a;}

    int main()
    {
    cout <<  min1(3.0,4.0)<<endl;
    cout << min1<double,double>(7,8)<<endl;  //Error :no matching function for call to 'min<int,int>'
                                             //Why do not support Explicit Template Arguments;
    return 1;
    }

    tom

     
    • Nobody/Anonymous

      error line shoud be: cout <<min1<double>(7,8)<<endl;

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.