Passage de tableau de class ?
Alors voila mon petit probleme, je doit creer un programme capable de gerer des location de film.
Pour le moment je ne suis pas tres avancer mais je bloque sur une connerie...
J'ai mon main :
Code:
1 2 3 4 5 6 7 8 9 10 11
| #include <string.h>
#include <fstream>
#include <iostream>
#include <stdio.h>
#include "GestionFilm.h"
int main(void) {
GestionFilm gf;
gf.lectureFichier("Film.txt");
} |
J'ai Film.h :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| #ifndef FILM_H
#define FILM_H
#include <string.h>
using namespace std;
class Film {
private:
int numFilm;
string titre;
string langue;
int nbDispo;
};
#endif |
Et finalement j'ai GestionFilm.h :
Code:
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 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
#include <fstream>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include "Film.h"
using namespace std;
const int MAXNBFILM = 100;
class GestionFilm {
private :
Film tabFilm[MAXNBFILM];
public :
void lectureFichier(string fichier,Film tabFilm[], int MAXNBFILM);
};
// Recoi le nom du fichier a traiter et remplie le tableau de film
void GestionFilm::lectureFichier(string fichier, Film &tab, int taille) {
ifstream ffilm((char*)fichier.c_str());
if ( ffilm ) {
string ligne; // chaque ligne lue
int index = 0;
while ( getline( ffilm, ligne ) ) { // Pour chaque ligne
char *token;
token = strtok((char*)ligne.c_str(),";");
int i = 0;
while (token != NULL) {
//printf("The token is: %s\n", token);
switch(i) {
case 0 :
printf("0: %s\n",token);
break;
case 1 :
printf("1: %s\n",token);
break;
case 2 :
printf("2: %s\n",token);
break;
case 3 :
printf("3: %s\n",token);
break;
default:
i = 0;
break;
}
++i;++index;
token = strtok(NULL,";");
}
}
}
} |
J'aimerais passer le tableau de film a la fonction LectureFilm, mais impossible je n'y arrive definitivement pas, j'ai essayé pas mal de chose et tombe suovent sur l'erreur suivante :
Code:
1 2 3 4 5 6
| In file included from part2.cpp:5:
GestionFilm.h:19: erreur: prototype for void GestionFilm::lectureFichier(std::string, Film&, int) does not match any in class GestionFilm
GestionFilm.h:14: erreur: candidate is: void GestionFilm::lectureFichier(std::string, Film*, int)
part2.cpp: In function int main():
part2.cpp:17: erreur: no matching function for call to GestionFilm::lectureFichier(const char [9])
GestionFilm.h:14: note: candidats sont: void GestionFilm::lectureFichier(std::string, Film*, int) |
J'ai vu qu'il etait possible d'utiliser un vecteur, mais l'une des contrainte de l'enoncer et d'avoir un tableau de film !!!
Est ce que quelqu'un pourrait m'aider, je tourne en rond....
Ah je precisse le fichier Film.txt est du type :
Code:
1 2
| aaa;bbbb;cccc;ddd
eee;ffffff;ddd;rrr |