Presentation is loading. Please wait.

Presentation is loading. Please wait.

Comments, Prototypes, Headers & Multiple Source Files

Similar presentations


Presentation on theme: "Comments, Prototypes, Headers & Multiple Source Files"— Presentation transcript:

1 Comments, Prototypes, Headers & Multiple Source Files
Modular Code Comments, Prototypes, Headers & Multiple Source Files

2 Comments Functions designed to:
Be reused Be an abstraction Function comments preserve the abstraction "OK, how do I use this thing?"

3 Doxygen Format Put /** block comment before function:
@brief Description of NAME what parameter called NAME is for @return What is returned

4 Review Structured comments Used for: Machine readable
Automatic documentation Tooltips in IDE?

5 Function Prototypes Function Prototype : Function header with no body (followed by ;) Declares a function

6 Prototypes Can use a declared function even if not defined yet
Not needed until linking is done

7 Function Libraries & Headers
Function Library : Collection of functions for use elsewhere in program Header files Place to store high level definitions for a code library Should not have code, just declarations .h extension

8 Compilation Header tells each file functions exist
Code in .cpp so that only one definition is compiled

9 Finding headers Include with < > looks in compiler defined directories Include with " " looks in your project, then regular directories

10 Guards Don't want same definitions included twice Preprocessor guard:
Easy to do by accident: Include A and B, B also includes A Preprocessor guard: #ifndef : if this symbol not defined, read until #endif #define : define a symbol HELPERS_H made up should be unique


Download ppt "Comments, Prototypes, Headers & Multiple Source Files"

Similar presentations


Ads by Google