C++ undefined reference to defined function

The declaration and definition of insertLike have different writeTo parameters.

In your header file, you have:

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

while 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.

Leave a Comment