Header file question
I''m reading a book on C++ and I''m not quite getting something. You have the header file that prototypes your class. Then you have a .cpp that defines your functions. What do you include in your file that actually uses all of this? .h or .cpp? The book is making a header file, then a definition file that includes the header, then the actual problem-solving file that includes the definition .cpp file. But I see a lot of source files that include the .h. So where is the definition file? And if your file using the .h file IS the definition, why is the book using a seperate file for this?
Can anyone make sense of my paragraph and then tell me what''s going on?
subnet_rx
You shouldn''t include .cpp files. You can, but strange things can happen. Under normal circumstances, you create your header and source (.cpp) files and include the header in other headers and/or source files that requires your class/function/variable definitions. The compiler handles all the code resolution and relocation.
[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
[ GDNet Start Here | GDNet FAQ | MS RTFM | STL | Google ]
Thanks to Kylotan for the idea!
I typed out a whom article on how linkers and compiler work but I decided that''d get confusing.
You put the class definitions in the header files. And you put it''s methods in its own CPP file.
You #include the .h file. The compiler and linker will handle the rest.
You put the class definitions in the header files. And you put it''s methods in its own CPP file.
You #include the .h file. The compiler and linker will handle the rest.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement