Lecture 6 Flashcards
Code Library
Allow you to have additional functionality by letting you access functions on that file. Libraries typically include a header and implementation file.
Header file
Contains definitions and declarations for functions in the library and shows you how to access those functions.
Typically includes the extension .hpp or .h. Extension not needed when using libraries from the c++ standard library since the extension is implied.
Implementation file
Includes commands and details. Typically includes the extension .c or .cpp. Extension not needed if it is part of the c++ standard library.
.h or .hpp
Extension for header file. Pp stands for plus plus
.c or .cpp
Extension for implementation file. Pp stands for plus plus.
Benefits to using libraries
- Separation of ideas in code
- Reuse code in libraries so you don’t have to come up with it again.
Object file
Machine instructions that the program, header, and implementation files are each compiled in to.
include
Allows you to access a library when followed by the library name in <> or “”
include convention
<> for c++ standard libraries
“” for other libraries
Linker
Combines the object file from the main program with the library’s object file to make an executable file.
Executable file
File that has all the information needed from both the program file and the library file. Can run on it’s own.
When are libraries compiled?
Ahead of time–if you write your own, you will need to compile it ahead of time as well.
C++ Standard Libraries
Libraries that come with C++ download
Common standard libraries
Cmath, ctime, iostream, cstdlib
Function
Made of function name followed by arguments in parentheses and commands that follow in curly braces