Compiler error c2780 of STD: min and STD: Max

Source: Internet
Author: User

Code

# Include <iostream>
# Include <algorithm> // STD: min
# UNDEF min
Int main ()
{
Float a = 15.0f;
Float C;
C = STD: min (10, );
Printf ("% F", B );
Getchar ();
}

Error Message

Error 1 error c2780: 'const _ ty & STD: min (const _ ty &, const _ ty &, _ Pr) ': expects 3 arguments-2 provided
Error2error c2782: 'const _ ty & STD: min (const _ ty &, const _ ty &) ': Template parameter' _ ty 'is ambiguous
3 intelliisense: no instance of overloaded function "STD: min" matches the argument list
4 intelliisense: Too few arguments in function call

Unction template (C ++ 98)

Template<ClassT>ConstT & min (ConstT &,ConstT & B ){Return! (B <)? A: B;// Or: return! Comp (B, )? A: B; for version (2)}
Error Analysis
The STL template used by min. In the prototype of the algorithm, the parameters A and B should be of the same type, c = STD: min (10, ); 10. A mismatch with the type causes the following error.
Modification Method
Method 1
C = STD: min (10.0f, );
Method 2
Float B = 10;
c=std::min(b,a);
Method 3
C = STD: min (float) 10.0, );

 

 

Compiler error c2780 of STD: min and STD: Max

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.