Search code examples
c++object-files

How to compile class.cpp and class.hpp to one .o file?


How to compile class.cpp and class.hpp to one .o file? If I can, please tell me how. If I can't, please tell me what should I do if I want to do something similar. These are the latest version of my classes(they're not completed yet.): OptionParser.cpp, OptionParser.hpp.


Solution

  • To do so you need to just include class.hpp to you class.cpp file. It can be done like

    #include "class.hpp"

    So you just need to have both in same folder and after that you need to add above line in class.cpp and then just compile and run the executable.