‘max_element’ was not declared in this scope

This is a discussion on ‘max_element’ was not declared in this scope within the C++ Programming forums, part of the General Programming Boards category; Dear All, I am trying to compile a code and I get the following. g++ -O3 -Wall -ffast-math -ffinite-math-only -c ...

  1. #1
    Registered User
    Join Date
    Jul 2009
    Posts
    9

    ‘max_element’ was not declared in this scope

    Dear All,

    I am trying to compile a code and I get the following.

    g++ -O3 -Wall -ffast-math -ffinite-math-only -c dpdconfig.cpp
    dpdconfig.cpp: In member function ‘void DpdConfig::SetCellDimensions()’:
    dpdconfig.cpp:293: error: ‘max_element’ was not declared in this scope
    make: *** [dpdconfig.o] Error 1


    Could you please suggest me a solution?

    Thanks in advance.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Declare max_element as a variable? (Or, if you want the standard function, write the function call with (parentheses) and make sure you include the headers.)

  3. #3
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,793
    If it's the STL function your talking about, then you'll need to #include the <algorithm> header and deal with the namespace issue as appropriate.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xy was not declared in this scope: compiler error!
    By twilight in forum C++ Programming
    Replies: 41
    Last Post: 08-13-2009, 12:33 PM
  2. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 12:03 PM
  4. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  5. Nested loop frustration
    By caroundw5h in forum C Programming
    Replies: 14
    Last Post: 03-15-2004, 08:45 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21