Erreur class has not been declared
Résolu
velocity
Messages postés
204
Date d'inscription
Statut
Membre
Dernière intervention
-
velocity Messages postés 204 Date d'inscription Statut Membre Dernière intervention -
velocity Messages postés 204 Date d'inscription Statut Membre Dernière intervention -
Bonjour à tous,
je suis en train de faire un petit exercice en c++ et je rencontre un problème qui m'empêche de terminer. voici le code :
//fichier ProfDeGym.h
//fichier TourDePiste.h
//fichier ProfDeGym.cpp
//fichier TourDePiste.cpp
//fichier main.cpp
quand je compile le main sous ubuntu, j'ai les erreurs suivantes:
velocity@velocity-laptop:~/Documents/proj1$ gcc -o main.o main.cpp
In file included from main.cpp:2:
ProfDeGym.h:11: error: `TourDePiste' has not been declared
ProfDeGym.h:15: error: variable or field `tourFini' declared void
ProfDeGym.h:15: error: `TourDePiste' was not declared in this scope
ProfDeGym.h:15: error: `tour' was not declared in this scope
main.cpp: In function `int main()':
main.cpp:6: error: `TourDePiste' was not declared in this scope
main.cpp:6: error: expected `;' before `tour'
main.cpp:9: error: `tour' was not declared in this scope
main.cpp:11: error: expected unqualified-id before `.' token
main.cpp:14: error: `cout' was not declared in this scope
main.cpp:14: error: expected primary-expression before `<<' token
merci d'avance,
0
je suis en train de faire un petit exercice en c++ et je rencontre un problème qui m'empêche de terminer. voici le code :
//fichier ProfDeGym.h
#ifndef H_ProfDeGym #define H_ProfDeGym using namespace std; #include "TourDePiste.h" class ProfDeGym{ public : void tourFini(TourDePiste&); }; void ProfDeGym::tourFini(TourDePiste& tour){ if(tour.nbTours>0) tour.nbTours--; } #endif
//fichier TourDePiste.h
#ifndef H_TourDePiste #define H_TourDePiste using namespace std; class TourDepiste{ int getTours(){return nbTours;} void setTours(int & nbTours){this->nbTours=nbTours;} friend void tourFini(); private: int nbTours; }; #endif
//fichier ProfDeGym.cpp
#include <ProfDeGym.h>
//fichier TourDePiste.cpp
#include <TourDePiste.h>
//fichier main.cpp
#include "TourDePiste.h" #include "ProfDeGym.h" int main(){ TourDePiste tour = new TourDePiste(); ProfDeGym(); tour.setTours(10); for(int i=0;i<5;i++){ ProfDeGym.TourFini(tour); } cout << "nbTour" << tour.getTours(); << "\n"; return 0; }
quand je compile le main sous ubuntu, j'ai les erreurs suivantes:
velocity@velocity-laptop:~/Documents/proj1$ gcc -o main.o main.cpp
In file included from main.cpp:2:
ProfDeGym.h:11: error: `TourDePiste' has not been declared
ProfDeGym.h:15: error: variable or field `tourFini' declared void
ProfDeGym.h:15: error: `TourDePiste' was not declared in this scope
ProfDeGym.h:15: error: `tour' was not declared in this scope
main.cpp: In function `int main()':
main.cpp:6: error: `TourDePiste' was not declared in this scope
main.cpp:6: error: expected `;' before `tour'
main.cpp:9: error: `tour' was not declared in this scope
main.cpp:11: error: expected unqualified-id before `.' token
main.cpp:14: error: `cout' was not declared in this scope
main.cpp:14: error: expected primary-expression before `<<' token
merci d'avance,
0
A voir également:
- Class has not been declared c++
- Bios has been reset - Forum BIOS
- Warning your chassis has been opened ✓ - Forum Matériel & Système
- No boot disk has been detected or the disk has failed - Forum Disque dur / SSD
- Signal cable not connected ✓ - Forum Ecran
- Nvcontainer windows class - Forum Carte graphique
8 réponses
En premier essai, j'ai utilisé eclipse mais il ne compile pas, puis j'ai passé à Code::Blocks, là aussi j'ai plusieurs erreurs d'include et autres que j'ai pas compris et puisque j'ai pas beaucoup de temps j'ai choisi d'utiliser ubuntu sous virtual Box et voilà le résultat !
KX
Messages postés
16761
Date d'inscription
Statut
Modérateur
Dernière intervention
3 020
Si tu es sous Windows, Dev-C++ est pas mal, pas la peine de virtualiser pour ça !