Erreur de compilation "undefined reference"
Bonsoir à tous
Je suis un débutant en programation, et j'ai un problème d'executer mon petit programme qui affiche "Hello Word" à l'ecran, mais en utilisant une classe sous C++; Cette classe est découpée en trois fichiers séparés telques hello.h, hello.cc et test_hello.cc qui contient la foction main(); donc quand j'essaie de compiler le test_hello.cc le compilateur me renvoyer le message suivant:
Citation:
/tmp/ccFFwWMm.o: In function `main':
test_Hello.cc:/(.text+0x76): undefined reference to `Hello::Hello()'
test_Hello.cc:/(.text+0xad): undefined reference to `Hello::Hello(std::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
test_Hello.cc:/(.text+0xef): undefined reference to `Hello::affiche()'
test_Hello.cc:/(.text+0x13a): undefined reference to `Hello::affiche()'
collect2: ld returned 1 exit status
pour mieux comprendre voici mes codes:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| #ifndef Hello_H
#include<string>
#define Hello_H
using namespace std;
class Hello
{
public:
Hello();
Hello(string s);
void affiche();
private:
string msg;
};
#endif |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
#include <string>
using namespace std;
#include "hello.h"
Hello::Hello()
{
msg = "Hello Word"; //affectation une valeur à mon string msg
}
Hello::Hello(string s)
{
msg = s;
}
void Hello::affiche()
{
cout<< msg <<endl;
} |
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| #include<iostream>
#include <string>
#include "hello.h"
using namespace std;
int main()
{
Hello h1;
Hello h2("Bonjour");
h1.affiche();
h2.affiche();
return 0;
} |
si quelqu'un peut m'aider ?? je suis à l'écoute:roll: