CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Threaded View

  1. #1
    Join Date
    Mar 2002
    Location
    AhuhA
    Posts
    204

    Smile Hi

    I wrote a function like this to get the largest value among the threes, but the returned value when 'cout'ed in the main function is the same-->12.4242. Could anyone here tell me why ?

    template <typename T>
    T max(T x,T y,T z){
    T holdmax=x;
    if(y>=holdmax)
    holdmax=y;
    if(z>=holdmax)
    holdmax=z;
    return holdmax;
    }
    int main(){
    cout<<max(12.42422,12.42421,12.42420)<<endl;
    return 0;
    }
    Thanks in advance


    Regards,

    [Yves: try to find a better title for your post than 'Hi' ]
    Last edited by Yves M; February 10th, 2003 at 12:11 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured