Menu

max_element

2002-12-12
2012-09-26
  • Derek Baker

    Derek Baker - 2002-12-12

    Can't get this test program to compile on Dev 4.9.7.0./gcc 3.2.

    #include <algorithm>
    #include <cstdlib>
    #include <iostream>
    #include <vector>

    using namespace std;

    vector<int>v;
    int num = 10000;

    int main()
    {
        for(int i= 0; i< num; ++i)
        {
            v.push_back(rand());
        }
       
        vector<int>::iterator it = v.max_element(v.begin(), v.end());
       
       
        cout << endl << endl;
        system("PAUSE");

    return 0;
    }

    Anyone want to point out the stupid mistake I've made, or failing that run it on their machine?

    Derek

     
    • Nobody/Anonymous

      output on dev 4.9.6.9
      gcc version 2.95.3-6 (mingw special)

      18 K:\Documents and Settings\lenhan\Desktop\Untitled1.cpp
      no matching function for call to `vector<int,allocator<int> >::max_element (int *, int *)'

      might not be a compiler problem.

      Nhan

       
    • Derek Baker

      Derek Baker - 2002-12-12

      Thanks Nhan,

      It's not too much of a problem as the manual code is easy to write,but it's part of the standard library so slightly worrying that it is missing.

      Derek

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.