How can I avoid including class implementation files?

前端 未结 7 885
轮回少年
轮回少年 2020-11-29 11:45

Instead of doing

#include \"MyClass.cpp\"

I would like to do

#include \"MyClass.h\"

I\'ve read online tha

7条回答
  •  广开言路
    2020-11-29 12:31

    Cpp files should be defined in your compiler script to be compiled as object files.

    What ide are you using? I am going to assume you are compiling with gcc, so here is the command to compile two .cpp files into one executable

    gcc -o myclasses.out myclass.cpp myotherclass.cpp
    

    You should only use #include to include class definitions, not the implentation

提交回复
热议问题