Bonjour j'ai un petit problème avec mes fonctions virtuelles. J'ai donc 4 fichiers.
Joint.h
Joint.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
34
35
36
37 #ifndef DEF_JOINT #define DEF_JOINT #include <string> #include <ode/ode.h> class Joint { public: // Constructeur Joint(); // Méthodes /* Renvoie le JointID */ dJointID getJointID(); /* Renvoie le nom du Joint */ std::string getName(); /* Renvoie les BodyID attaché aux joint (0 = premier bodyID, 1 = deuxième bodyID) */ dBodyID getBodyID(int body); // Méthodes virtuelles /* Permet de rentrer la velocité du moteur */ virtual void setVelocity(double velocity); /* Permet de rentrer la force du moteur */ virtual void setMaxForce(double force); protected: // Attributs /* Joint */ dJointID m_joint; /* Le nom du Joint */ std::string m_name; }; #endif
MoteurSimple.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
32
33
34
35 #include "Joint.h" // Constructeur Joint::Joint() { m_joint = NULL; } // Méthodes /* Renvoie le JointID */ dJointID Joint::getJointID() { return m_joint; } /* Renvoie le nom du Joint */ std::string Joint::getName() { return m_name; } /* Renvoie les BodyID attaché aux joint (0 = premier bodyID, 1 = deuxième bodyID) */ dBodyID Joint::getBodyID(int body) { dBodyID tempBodyID = dJointGetBody(m_joint, body); return tempBodyID; } // Méthodes virtuelles /* Permet de rentrer la velocité du moteur */ void setVelocity(double velocity) { } /* Permet de rentrer la force du moteur */ void setMaxForce(double force) { }
MoteurSimple.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
34 #ifndef DEF_MOTEURSIMPLE #define DEF_MOTEURSIMPLE #include <string> #include <ode/ode.h> #include "Joint.h" class MoteurSimple : public Joint { public: // Constructeur MoteurSimple(dWorldID world, std::string name, dBodyID body1, dBodyID body2, double axe_pos_x, double axe_pos_y, double axe_pos_z, double axe_rot_x, double axe_rot_y, double axe_rot_z); // Destructeur ~MoteurSimple(); // Méthodes virtuelles /* Permet de rentrer la velocité du moteur */ virtual void setVelocity(double velocity); /* Permet de rentrer la force du moteur */ virtual void setMaxForce(double force); private: // Attributs }; #endif
Le code compile correctement mais j'ai un problème lors de l'édition du lien:
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 #include "MoteurSimple.h" // Constructeur MoteurSimple::MoteurSimple(dWorldID world, std::string name, dBodyID body1, dBodyID body2, double axe_pos_x, double axe_pos_y, double axe_pos_z, double axe_rot_x, double axe_rot_y, double axe_rot_z) { m_name = name; m_joint = dJointCreateHinge(world, 0); dJointAttach (m_joint, body1, body2); dJointSetHingeAnchor (m_joint, axe_pos_x, axe_pos_y, axe_pos_z); dJointSetHingeAxis (m_joint, axe_rot_x, axe_rot_y, axe_rot_z); } // Méthodes virtuelles /* Permet de rentrer la velocité du moteur */ void MoteurSimple::setVelocity(double velocity) { dJointSetHingeParam (m_joint, dParamVel, velocity); } /* Permet de rentrer la force du moteur */ void MoteurSimple::setMaxForce(double force) { dJointSetHingeParam (m_joint, dParamFMax, force);
j'ai ces erreurs:
Joint.obj : error LNK2001: symbole externe non résolu "public: virtual void __thiscall Joint::setMaxForce(double)" (?setMaxForce@Joint@@UAEXN@Z)
Joint.obj : error LNK2001: symbole externe non résolu "public: virtual void __thiscall Joint::setVelocity(double)" (?setVelocity@Joint@@UAEXN@Z)
Je crois comprendre que cela vien de mes fonctions virtuelles mais je ne comprend pas pourquoi. Peut etre une erreur de programmation. Si quelqu'un peu m'aider à retrouver ce problème. (j'ai déjà eu ce problème et résolu d'uneautre manière sans passer par les fonctions virtuelles, mais la je suis obligé)







Répondre avec citation





Cafuro est un outil SNMP dont le but est d'aider les administrateurs système et réseau à configurer leurs équipements SNMP réseau.
Partager