直接g++编译 例如我假设有一个cpp文件test.pp,想引用自己写的hello.cpp里面的 hello.h #ifndef HELLO_H #define HELLO_H class hello{ public: int plus(int a,int b