How to find the source code of functions?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Steel546
    New Member
    • Mar 2009
    • 25

    How to find the source code of functions?

    I want to understand why certain functions do certain things. Such as in a linked list, I'm looking for the source code behind the list.at(), or list.resize() functions.

    cplusplus.com only gives references, but does anyone know where to find the behind the scenes work? Thanks.
  • Banfa
    Recognized Expert Expert
    • Feb 2006
    • 9067

    #2
    All the C++ containers are template, its in the name STL - Standard Template Library.

    What that means is that they are not supplied as compiled code because that is not how templates work, when a template is used the compiler uses the code from the template and the types supplied as template parameters to create the code for the class that it then compiles.

    What this means is that the code for something like list::at will be in your compilers released directories. Try starting by looking in the header <list>, often (well in gcc certainly) what this mainly does is include other headers but the code for the list class is in one of these headers.

    However you are going to require very good knowledge of C++ syntax.

    Comment

    Working...