Click here to Skip to main content
15,920,217 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: problems about Template using Pin
jeansea3-Mar-09 4:15
jeansea3-Mar-09 4:15 
GeneralRe: problems about Template using Pin
Cedric Moonen3-Mar-09 4:21
Cedric Moonen3-Mar-09 4:21 
GeneralRe: problems about Template using Pin
jeansea3-Mar-09 5:02
jeansea3-Mar-09 5:02 
GeneralRe: problems about Template using Pin
Stuart Dootson3-Mar-09 4:24
professionalStuart Dootson3-Mar-09 4:24 
GeneralRe: problems about Template using Pin
jeansea3-Mar-09 5:08
jeansea3-Mar-09 5:08 
JokeRe: problems about Template using Pin
Stuart Dootson3-Mar-09 6:31
professionalStuart Dootson3-Mar-09 6:31 
GeneralRe: problems about Template using Pin
CPallini3-Mar-09 5:54
mveCPallini3-Mar-09 5:54 
AnswerRe: problems about Template using Pin
Stuart Dootson3-Mar-09 4:17
professionalStuart Dootson3-Mar-09 4:17 
jeansea wrote:
when i run the result is show wrong


When you run what?

As I expected, you get a compiler error when you try and compile that code, because the standard library already defines a template min function. You need to specify which min you want, by specifying that you want the 'no namespace' version (for that is yours) like this - oh, and you don't need to specify template parameters for functions if the function argument's types unambiguously specify the template parameters:

c = ::min(a, b);


Oh - and using namespace std; is bad form - use a using declaration instead. In your case, that would be 'using std::cout'. Those changes leave your program like this:

#include<iostream>
using std::cout;

template<typename Type>
Type min(Type a,Type b)
{
   return a<b?a:b;
}

int main()
{
   int a = 0, b = 1, c = 3;
   c = ::min(a,b);
   cout<<c;
}


Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p

JokeRe: problems about Template using Pin
Nemanja Trifunovic3-Mar-09 4:27
Nemanja Trifunovic3-Mar-09 4:27 
JokeRe: problems about Template using Pin
Stuart Dootson3-Mar-09 5:47
professionalStuart Dootson3-Mar-09 5:47 
JokeRe: problems about Template using Pin
Eytukan3-Mar-09 6:57
Eytukan3-Mar-09 6:57 
JokeRe: problems about Template using Pin
Stuart Dootson3-Mar-09 8:07
professionalStuart Dootson3-Mar-09 8:07 
JokeRe: problems about Template using Pin
Eytukan3-Mar-09 17:18
Eytukan3-Mar-09 17:18 
GeneralRe: problems about Template using Pin
CPallini3-Mar-09 22:46
mveCPallini3-Mar-09 22:46 
GeneralRe: problems about Template using Pin
CPallini3-Mar-09 22:45
mveCPallini3-Mar-09 22:45 
QuestionShared pointer in VS2008 Pin
vibindia3-Mar-09 3:51
vibindia3-Mar-09 3:51 
AnswerRe: Shared pointer in VS2008 Pin
Stuart Dootson3-Mar-09 3:57
professionalStuart Dootson3-Mar-09 3:57 
QuestionWaitCommEvent Pin
komofilms773-Mar-09 3:05
komofilms773-Mar-09 3:05 
AnswerRe: WaitCommEvent Pin
David Crow3-Mar-09 3:21
David Crow3-Mar-09 3:21 
AnswerRe: WaitCommEvent Pin
Stuart Dootson3-Mar-09 4:07
professionalStuart Dootson3-Mar-09 4:07 
Questionconvert cstring to LPBYTE Pin
amit.code3-Mar-09 2:58
amit.code3-Mar-09 2:58 
AnswerRe: convert cstring to LPBYTE Pin
Cedric Moonen3-Mar-09 3:02
Cedric Moonen3-Mar-09 3:02 
GeneralRe: convert cstring to LPBYTE Pin
amit.code3-Mar-09 3:08
amit.code3-Mar-09 3:08 
AnswerRe: convert cstring to LPBYTE Pin
David Crow3-Mar-09 3:05
David Crow3-Mar-09 3:05 
GeneralRe: convert cstring to LPBYTE Pin
amit.code3-Mar-09 3:12
amit.code3-Mar-09 3:12 

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.