Header Files And Header Guards Flashcards

1
Q

Header files

A

Propregage declarations to code files, allow us to put declaration in one location and then impart them whenever we need them

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Header files consist of

A

Header guard and content of header file (forward declarations)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Headers and code files

A

It should be added using quotes not brackets

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Angled brackets

A

Used to tell the preprocessor that we are including a header file that was included with the compiler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Double quotes

A

Tells the preprocessor that this is user-defined header file

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Transitive

A

Includes header files that are inside of header file, added implicitly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Order of #includes

A

User defined, 3ed party library, standard library, added implicitly

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Best practices of header files

A
  • include header guards
  • do not define variables and functions in header files
  • name with the same name as source files association
  • each header should have specific job and be independent
  • mind which files you should explicitly include
  • each header should compile on its own
  • only #include what you need
  • do not #include .cpp files
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Header guards

A

Conditional compilation directives that take #ifndef, #define, #endif; they are named in all caps using underscores

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Goal of header guards

A

Prevent a code file from receiving more than one copy of a guard header

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

pragma once

A

Serves the same purpose as header guards

How well did you know this?
1
Not at all
2
3
4
5
Perfectly