Bonjour à tous.

Je tente de créer deux classes : Recherche et Contrainte.
Chaque Recherche possède des contraintes et chaque contrainte est en fait un pointeur sur une recherche.

Pour plus de détail, voici mes classes :


Recherche.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
 
#include <iostream>
#include <vector>
#include <string>
#include "Contrainte.h"
#include "Recherche.h"
 
using namespace std;
 
Recherche::Recherche( std::string NOM , int GID , int METAL , int CRISTAL , int DEUT )
{
	nom = NOM ;
	gid = GID ;
	metal = METAL ;
	cristal = CRISTAL ;
	deuterium = DEUT ;
	niveau = 0 ;
}
 
int Recherche::getNiveau()
{
	return niveau ;
}
 
void Recherche::setNiveau( int niv )
{
	niveau = niv ;
}
 
void Recherche::addContrainte ( Recherche* objet , int niv )
{
	contraintes.push_back( Contrainte( objet , niv ) );
}
Recherche.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
 
#ifndef RECHERCHE_H
#define RECHERCHE_H
 
#include <vector>
#include <string>
#include "Contrainte.h"
 
class Contrainte;
 
class Recherche
{
	private:
 
	std::string nom ;
	int gid ;
	int metal ;
	int cristal ;
	int deuterium ;
	int niveau ;
	std::vector<Contrainte> contraintes ;
 
	public:
 
	Recherche( std::string NOM , int GID , int METAL , int CRISTAL , int DEUT );
	int getNiveau ();
	void setNiveau ( int niv );
	void addContrainte ( Recherche* objet , int niv );
};
 
#endif
Contrainte.cpp
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 
#include <iostream>
#include "Contrainte.h"
#include "Recherche.h"
 
using namespace std;
 
Contrainte::Contrainte ( Recherche* recherche , int niv )
{
	objet = recherche ;
	niveau = niv ;
}
 
bool Contrainte::isValide ()
{
	return ( (*objet).getNiveau() >= niveau );
}
et Contrainte.h
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
 
#ifndef CONTRAINTE_H
#define CONTRAINTE_H
 
#include "Recherche.h"
 
class Contrainte
{
	private:
 
	Recherche* objet ;
	int niveau ;
 
	public:
 
	Contrainte ( Recherche* recherche , int niv );
	bool isValide();
};
 
#endif
Le problème est que j'ai quelques problèmes avec (je pense) les pointeurs.

À la compilation avec gcc j'obtient une erreur assez illisible :
/usr/lib/gcc/i486-linux-gnu/4.4.1/../../../../lib/crt1.o: In function `_start':
/build/buildd/eglibc-2.10.1/csu/../sysdeps/i386/elf/start.S:115: undefined reference to `main'
/tmp/cclAY4Ci.o: In function `__static_initialization_and_destruction_0(int, int)':
Contrainte.cpp.text+0x69): undefined reference to `std::ios_base::Init::Init()'
Contrainte.cpp.text+0x6e): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cclAY4Ci.o.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
/tmp/cckuTJyD.o: In function `Recherche::Recherche(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, int)':
Recherche.cpp.text+0xf): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
Recherche.cpp.text+0x2f): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Recherche.cpp.text+0x8b): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/cckuTJyD.o: In function `Recherche::Recherche(std::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int, int, int)':
Recherche.cpp.text+0xab): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string()'
Recherche.cpp.text+0xcb): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator=(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)'
Recherche.cpp.text+0x127): undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string()'
/tmp/cckuTJyD.o: In function `__static_initialization_and_destruction_0(int, int)':
Recherche.cpp.text+0x1a5): undefined reference to `std::ios_base::Init::Init()'
Recherche.cpp.text+0x1aa): undefined reference to `std::ios_base::Init::~Init()'
/tmp/cckuTJyD.o: In function `std::vector<Contrainte, std::allocator<Contrainte> >::_M_insert_aux(__gnu_cxx::__normal_iterator<Contrainte*, std::vector<Contrainte, std::allocator<Contrainte> > >, Contrainte const&)':
Recherche.cpp.text._ZNSt6vectorI10ContrainteSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_[std::vector<Contrainte, std::allocator<Contrainte> >::_M_insert_aux(__gnu_cxx::__normal_iterator<Contrainte*, std::vector<Contrainte, std::allocator<Contrainte> > >, Contrainte const&)]+0x227): undefined reference to `__cxa_begin_catch'
Recherche.cpp.text._ZNSt6vectorI10ContrainteSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_[std::vector<Contrainte, std::allocator<Contrainte> >::_M_insert_aux(__gnu_cxx::__normal_iterator<Contrainte*, std::vector<Contrainte, std::allocator<Contrainte> > >, Contrainte const&)]+0x288): undefined reference to `__cxa_rethrow'
Recherche.cpp.text._ZNSt6vectorI10ContrainteSaIS0_EE13_M_insert_auxEN9__gnu_cxx17__normal_iteratorIPS0_S2_EERKS0_[std::vector<Contrainte, std::allocator<Contrainte> >::_M_insert_aux(__gnu_cxx::__normal_iterator<Contrainte*, std::vector<Contrainte, std::allocator<Contrainte> > >, Contrainte const&)]+0x291): undefined reference to `__cxa_end_catch'
/tmp/cckuTJyD.o: In function `std::vector<Contrainte, std::allocator<Contrainte> >::_M_check_len(unsigned int, char const*) const':
Recherche.cpp.text._ZNKSt6vectorI10ContrainteSaIS0_EE12_M_check_lenEjPKc[std::vector<Contrainte, std::allocator<Contrainte> >::_M_check_len(unsigned int, char const*) const]+0x36): undefined reference to `std::__throw_length_error(char const*)'
/tmp/cckuTJyD.o: In function `__gnu_cxx::new_allocator<Contrainte>::deallocate(Contrainte*, unsigned int)':
Recherche.cpp.text._ZN9__gnu_cxx13new_allocatorI10ContrainteE10deallocateEPS1_j[__gnu_cxx::new_allocator<Contrainte>::deallocate(Contrainte*, unsigned int)]+0xd): undefined reference to `operator delete(void*)'
/tmp/cckuTJyD.o: In function `__gnu_cxx::new_allocator<Contrainte>::allocate(unsigned int, void const*)':
Recherche.cpp.text._ZN9__gnu_cxx13new_allocatorI10ContrainteE8allocateEjPKv[__gnu_cxx::new_allocator<Contrainte>::allocate(unsigned int, void const*)]+0x24): undefined reference to `std::__throw_bad_alloc()'
Recherche.cpp.text._ZN9__gnu_cxx13new_allocatorI10ContrainteE8allocateEjPKv[__gnu_cxx::new_allocator<Contrainte>::allocate(unsigned int, void const*)]+0x32): undefined reference to `operator new(unsigned int)'
/tmp/cckuTJyD.o.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
/tmp/cckuTJyD.o.eh_frame+0x4b): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
Pouvez vous m'orienter vers une solution. Merci d'avance.