Click here to Skip to main content
15,903,201 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: what wrong with this function template? Pin
DengJW25-May-04 2:47
DengJW25-May-04 2:47 
GeneralRe: what wrong with this function template? Pin
ilostmyid225-May-04 2:51
professionalilostmyid225-May-04 2:51 
GeneralRe: what wrong with this function template? Pin
DengJW25-May-04 3:14
DengJW25-May-04 3:14 
GeneralRe: what wrong with this function template? Pin
ilostmyid225-May-04 3:25
professionalilostmyid225-May-04 3:25 
GeneralRe: what wrong with this function template? Pin
DengJW25-May-04 3:36
DengJW25-May-04 3:36 
GeneralRe: what wrong with this function template? Pin
ilostmyid225-May-04 3:43
professionalilostmyid225-May-04 3:43 
AnswerRe: what wrong with this function template? Pin
Henrik Stuart25-May-04 2:49
Henrik Stuart25-May-04 2:49 
GeneralRe: what wrong with this function template? Pin
DengJW25-May-04 3:06
DengJW25-May-04 3:06 
thanks a lots.

now this code works:

#include <iostream><br />
<br />
template<class T> T max(T a, T b)<br />
 {<br />
   if (a > b)<br />
     return(a);<br />
   else<br />
     return(b);<br />
 }<br />
<br />
//float max(float, float);<br />
//int max(int, int);<br />
<br />
void main(void)<br />
 {<br />
	std::cout << "The maximum of 100 and 200 is " << <br />
     max(100, 200) << '\n';<br />
<br />
	std::cout << "The maximum of 5.4321 and 1.2345 is " << <br />
     max(5.4321, 1.2345) << '\n';<br />
 }


but why the definition of two functions, which have been commented out, not working?

BTW, I intended to make use of function template instead of max/min functions.


DJ
GeneralRe: what wrong with this function template? Pin
Henrik Stuart25-May-04 3:14
Henrik Stuart25-May-04 3:14 
GeneralRe: what wrong with this function template? Pin
DengJW25-May-04 3:31
DengJW25-May-04 3:31 
GeneralRe: what wrong with this function template? Pin
Henrik Stuart25-May-04 3:54
Henrik Stuart25-May-04 3:54 
AnswerI understand now. thanks,.. ilostmyid2 , henrik and papa Pin
DengJW25-May-04 4:20
DengJW25-May-04 4:20 
Questionhow to create temporary canvas Pin
Arun AC25-May-04 2:15
Arun AC25-May-04 2:15 
AnswerRe: how to create temporary canvas Pin
Anthony_Yio25-May-04 2:22
Anthony_Yio25-May-04 2:22 
GeneralRegex Pin
shiraztk25-May-04 1:24
shiraztk25-May-04 1:24 
GeneralRe: Regex Pin
Anthony_Yio25-May-04 2:18
Anthony_Yio25-May-04 2:18 
Generala question about email address of america Pin
includeh1025-May-04 0:53
includeh1025-May-04 0:53 
GeneralRe: a question about email address of america Pin
Maximilien25-May-04 0:59
Maximilien25-May-04 0:59 
General830305 - Invalid adjustment in RTL menus Pin
ilostmyid225-May-04 0:26
professionalilostmyid225-May-04 0:26 
Generalopen file dialog in wrong position Pin
si_6924-May-04 23:20
si_6924-May-04 23:20 
GeneralRe: open file dialog in wrong position Pin
jmkhael24-May-04 23:33
jmkhael24-May-04 23:33 
GeneralRe: open file dialog in wrong position Pin
si_6924-May-04 23:44
si_6924-May-04 23:44 
GeneralRe: open file dialog in wrong position Pin
jmkhael24-May-04 23:54
jmkhael24-May-04 23:54 
GeneralRe: open file dialog in wrong position Pin
si_6925-May-04 0:05
si_6925-May-04 0:05 
GeneralRe: open file dialog in wrong position Pin
jmkhael25-May-04 0:20
jmkhael25-May-04 0:20 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.