C++ undefined reference to defined function

前端 未结 6 949

I cannot figure out why this is not working. I will put up all three of my files and possibly someone can tell me why it is throwing this error. I am using g++ to compile the

6条回答
  •  别那么骄傲
    2021-02-03 20:47

    The declaration and definition of insertLike are different

    In your header file:

    void insertLike(const char sentence[], const int lengthTo, const int length, const char writeTo[]);

    In your 'function file':

    void insertLike(const char sentence[], const int lengthTo, const int length,char writeTo[]);

    C++ allows function overloading, where you can have multiple functions/methods with the same name, as long as they have different arguments. The argument types are part of the function's signature.

    In this case, insertLike which takes const char* as its fourth parameter and insertLike which takes char * as its fourth parameter are different functions.

提交回复
热议问题