Hi all-

I’m teaching myself C++ from a textbook and there’s a convention I’m starting to notice that doesn’t make sense to me, and it’s not explained in the book.

When creating a class, the convention seems to be to put the class declaration in a header file and put the member functions in a .cpp file. That part I understand, but the way the files are #included seems strange...

When you include a class definition in a program, you #include the header file for that class, right? But the header file doesn’t #include it’s .cpp counterpart, in fact it seems to be the other way around.

Why is it done this way? Seems like the program file should #include the .cpp file for the class instead of the header file.