- #1
Dschumanji
- 153
- 1
My computer science course is currently going over defining classes in C++. We do three things:
1) Create a header file that declares the class and save it as the class name appended with .h
2) Create a file that includes the header file in (1) and implements the class functions and save it as the class name appended with .cpp
3) Create a file that includes the header file in (1) and implements a main function to test the class.
My question is this: Why does the file in (3) only need to include the header file in (1) when the important things like the implementation of class functions in file (2) does not need to be included?
1) Create a header file that declares the class and save it as the class name appended with .h
2) Create a file that includes the header file in (1) and implements the class functions and save it as the class name appended with .cpp
3) Create a file that includes the header file in (1) and implements a main function to test the class.
My question is this: Why does the file in (3) only need to include the header file in (1) when the important things like the implementation of class functions in file (2) does not need to be included?