Erreur "undefined reference/unresolved external symbol" en C++ : causes et correction
Bonjour à tous ! Je suis débutant en C++ et je lutte depuis plusieurs heures avec une erreur que je ne comprends pas. Le compilateur affiche quelque chose comme :
```
undefined reference to `MyClass::myFunction()'
```
ou
```
unresolved external symbol "public: void __thiscall MyClass::myFunction(void)" (?myFunction@MyClass@@QAEXXZ) referenced in function _main
```
Voici mon code. J'ai trois fichiers :
**main.cpp :**
```cpp
#include "myclass.h"
int main() {
MyClass obj;
obj.myFunction();
return 0;
}
```
**myclass.h :**
```cpp
#ifndef MYCLASS_H
#define MYCLASS_H
class MyClass {
public:
void myFunction();
};
#endif
```
**myclass.cpp :**
```cpp
#include "myclass.h"
#include
void MyClass::myFunction() {
std::cout << "Hello from myFunction!" << std::endl;
}
```