Bonjour,
Je voudrais créer 3 types de constructeurs dans mon programme, mais le programme ne s’exécute pas. On m’affiche ces deux erreurs que je vois pour la première fois :
1>main.obj : error LNK2019: unresolved external symbol "public: __thiscall Notes::~Notes(void)" (??1Notes@@QAE@XZ) referenced in function _main
1>C:\Documents and Settings\khaoula\Mes documents\Visual Studio 2005\Projects\ex1tp3\Debug\ex1tp3.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\khaoula\Mes documents\Visual Studio 2005\Projects\ex1tp3\ex1tp3\Debug\BuildLog.htm"
1>ex1tp3 - 2 error(s), 0 warning(s)
Voici les fichiers que j’ai créés :
notes.h :
#include<iostream>
class Notes
{
private :
float test1, test2;
float DS, Examen;
float orale, TP;
bool avecTP;
public :
Notes():test1(0), test2(0), DS(0), Examen(0), orale(0), TP(0), avecTP(true){}
Notes(float t1, float t2, float d, float E, float o, float tp):test1(t1), test2(t2), DS(d), Examen(E), orale(o), TP(tp), avecTP(true){}
Notes(float t1, float t2, float d, float E, float o):test1(t1), test2(t2), DS(d), Examen(E), orale(o), avecTP(false){}
float CalculNCC();
float CalculMoyenne();
~Notes();
};
notes.cpp :
#include"notes.h"
float Notes::CalculNCC()
{
return (test1+test2+orale+2*DS)/5;
}
float Notes::CalculMoyenne()
{
if(avecTP)
return (0.3 * CalculNCC()) + (0.3 * TP)+(0.4 * Examen);
else
return (0.4 * CalculNCC()) + (0.6 * Examen);
};
main.cpp :
#include"notes.h"
using namespace std;
void main()
{
Notes N1(10, 12, 15, 11, 17, 9.5);
Notes N2(11.5, 13, 18, 10, 12.5);
cout<<"NCC1 = "<<N1.CalculNCC()<<"M1 = "<<N1.CalculMoyenne()<<endl;
cout<<"NCC2 = "<<N2.CalculNCC()<<"M2 = "<<N2.CalculMoyenne()<<endl;
if(N1.CalculMoyenne() > N2.CalculMoyenne())
cout<<"M1 est plus grand";
else
cout<<"M2 est plus grand";
}
Merci de vos réponses :)
La foudre et l'amour laissent les vêtements intacts et le coeur
en cendre...