简体   繁体   English

如何将 class.cpp 和 class.hpp 编译为一个 .o 文件?

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

How to compile class.cpp and class.hpp to one .o file?如何将 class.cpp 和 class.hpp 编译为一个 .o 文件? 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 .这些是我的类的最新版本(它们还没有完成。): OptionParser.cppOptionParser.hpp

To do so you need to just include class.hpp to you class.cpp file.为此,您只需将 class.hpp 包含到您的 class.cpp 文件中。 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.所以你只需要在同一个文件夹中,然后你需要在 class.cpp 中添加上面的行,然后编译并运行可执行文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM