Templates do not compile with dev c++ -


this question has answer here:

#include<conio.h> #include<iostream> using namespace std; template<class t> t min(t a,t b) { return (a>b)?a:b; } int main() { int x,y; cin>>x>>y; cout<<"min. of integer value is="<<min(x,y); //error call of overloaded function    ambiguous. float p,q; cin>>p>>q; cout<<"min. of floating value is="<<min(p,q);//same error above char c1,c2; cin>>c1>>c2; cout<<"min. of c1 , c2(basis of ascii values)="<<min(c1,c2);// same error    above getch(); return 0; } 

is there inbuilt feature of dev c++ doesnt support templates or there other error?

the reason there std::min, gets imported global namespace (due using namespace std;).

so have 2 different versions of min: version (which returns maximum...), , standard min.

either rename min-function, or remove (and use std::min instead).


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -