Where to put .h and .cpp(imp)??

I need some help trying to create a class and I am confused about where to put the files. When creating an executable program including a class where do you include the header file and the implementation file while using Visual Studio?
you want to keep the header file (.h) containing the definition of the class by itself and the definitions of the functions of the class in a .cpp file (the implementation file). In the implementation file, you include the .h file, and in the main .cpp file that includes the actual program, you also incllude the .h file.
Last edited on
Yep, there are some exceptions where you must write the definition in the header.

Just do it to separate the structure from the code, until you understand why. You probably will not understand the complications of writing everything in the header, and what the compiler must know to link your application. Eg one component is dependable on another which is dependable on the first one. This is just one of the many issues this helps to solve.
Last edited on
Topic archived. No new replies allowed.