cs31 lecture 17

X the same header can be included multiple times the

Info icon This preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: plementing the functions to be used The prototype of the functions to be used Adding some options to the compiler about the location of those 2 Adding items items 66 Creating a library x In a nutshell, a library is a set of functions (no ‘main()
’ In function)
 function)
 x When creating a library, a collection of .cpp and .hh files When are created by the developer are x Each file can be compiled as a stand-alone unit (-c option Each in GCC)
 to get object code in x The object code files are then packed into a single archive x The developer ships archive + headers, and/or source + The headers headers 67 A few observations x If the prototype is missing, the compiler yields a warning If (not an error)
 with many compilers (not The missing prototype may be “replaced” with dummy int return The type and arguments type x If the function is used before the header is included, then If the above error arise (same as missing header)
 the x Multiple headers may define the same function: be careful! x The same header can be included multiple times The (recommend to correctly protect it)
 (recommend 68 Namespace x Namespaces roughly groups together functions under a Namespaces common name prefix common x Good programming habit: use a specific namespace for a Good library library x Be careful: multiple different namespaces can define the Be same function same 69 More on namespaces x Syntax for declaring a namespace and functions in it: namespace <name> { [fun...
View Full Document

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern