Linking two .cpp and a .h files

后端 未结 8 896
小蘑菇
小蘑菇 2021-02-02 01:00

I\'m doing an exercise (from the third chapter of Thinking in C++) but I have a problem linking two .cpp files.

This is the exercise:

Create a h

8条回答
  •  清歌不尽
    2021-02-02 01:59

    It sounds like the file is not finding the functions appropriately. Is the header file included in both files? You can include it like:

    #include "myheader.h"
    

    Did you make sure to compile both files together? Such as:

    gcc -o myprogram file1.cpp file2.cpp

提交回复
热议问题