Bonjour,

je suis actuellement en train de créer un programme concernant les tournées de véhicules et je ne comprends pas une erreurs renvoyée par mon compilateur.
En fait lorsque j'ai commencé mon programme je n'avais pas pensé à l'utilité d'une variable mais je souhaite maintenant l'ajouter à mon constructeur.
Le problème est que le compilateur me dit que cet attribut n’existe pas.

J'utilise aussi fstream dans cette classe mais si je l'inclus dans mon .h les compilateur considère que la bibliothèque n'est pas inclus je n'ai pas trouvé de solution sur internet si je suis passé a coté je suis désolé pour le poste mais ça fait une semaine que je suis dessus et je commence a déprimer.

Je ne vous met que les .h et .cpp qui me posent problème quelques includes peuvent ne pas apparaître ici mais ils sont bien présent ailleurs dans le programme.

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
#ifndef TOURNEE_H
#define TOURNEE_H
 
#include <cstdlib>
#include <iostream>
#include <vector>
 
#include "Tache.h"
 
class Tournee
{
    public:
        Tournee();
        Tournee(int id);
 
        static void afficherTournees(std::vector<Tournee> const &v, std::vector<Tache> const &tache);
        static void chargementTournee(std::vector<Tournee> &v);
 
        std::string getSites(int i) const;
 
    private:
        int m_id;
        std::vector< std::vector<float> > m_villes;
        std::vector<std::string> m_nom_sites;
        std::vector<int> m_villes_parcourues;
 
        float getTemps(int i, int j) const;
 
        int getID() const;
        int getNbSites() const;
 
        void addSite(std::string nom);
        void addTemps(int i, int j, int temps);
};
 
#endif // TOURNEE_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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#include "Tournee.h"
 
#include <fstream>
 
using namespace std;
 
Tournee::Tournee() : m_id(0), m_villes(1,vector<int>(1)),  m_nom_sites(0), m_villes_parcourues(0){}
 
Tournee::Tournee(int id) : m_id(id), m_villes(1,vector<int>(1)),  m_nom_sites(0), m_villes_parcourues(0){}
 
int Tournee::getID() const
{
    return this->m_id;
}
 
int Tournee::getNbSites() const
{
    return this->m_nom_sites.size();
}
 
int Tournee::getTemps(int i, int j) const
{
    int temp;
    try
    {
        temp=this->m_villes[i][j];
    }
    catch(exception const& e)
    {
        cerr<<"ERREUR : "<<e.what()<<" : int Tournee::getTemps(int i, int j) const."<<endl;
    }
    return temp;
}
 
string Tournee::getSites(int i) const
{
    string temp;
    try
    {
        temp=this->m_nom_sites[i];
    }
    catch(exception const& e)
    {
        cerr<<"ERREUR : "<<e.what()<<" : string Tournee::getSites(int i) const."<<endl;
    }
    return temp;
}
 
void Tournee::addSite(string nom)
{
    this->m_nom_sites.push_back(nom);
//    this->m_villes_parcourues.push_back(0);
}
 
void Tournee::addTemps(int i, int j, int temps)
{
    vector <int> v(1);
 
    while((size_t)i>this->m_villes.size()-1)
    {
        this->m_villes.push_back(v);
    }
 
    while((size_t)j>this->m_villes[i].size()-1)
    {
        m_villes[i].push_back(1);
    }
 
    this->m_villes[i][j]=temps;
}
 
void Tournee::afficherTournees(vector<Tournee> const &v, vector<Tache> const &tache)
{
    for(size_t i(0);i<v.size();i++)
    {
        for(size_t j(0);j<tache.size();j++)
            if(v[i].getID()==tache[j].getID())
                cout<<endl<<tache[j].getNom()<<endl;
 
        cout<<v[i].getID()<<"\t"<<v[i].getNbSites()<<endl;
 
        for(int j(0); j<v[i].getNbSites();j++)
            cout<<v[i].getSites(j)<<endl;
 
        for(int j(0); j<v[i].getNbSites();j++)
        {
            for(int k(0); k<v[i].getNbSites();k++)
            {
                cout<<v[i].getTemps(j,k)<<"\t";
            }
            cout<<endl;
        }
    }
}
 
void Tournee::chargementTournee(vector<Tournee> &v)
{
    cout<<"Chargement des tournees."<<endl;
    string verif(""), s("");
    int n(0);
    ifstream fichier_tournee("C:/BdDs/tournee.sav");
//    ofstream fichier_test("C:/Users/resultat.txt", ios::app| ios::out);
    if(fichier_tournee)
    {
        while(!fichier_tournee.eof())
        {
//            fichier_test<<endl<<endl;
            fichier_tournee>>verif>>n>>s;
            if(verif=="id")
                v.push_back(Tournee(n));
            else if(verif=="OK")
                v[v.size()-1].addSite(s);
            else if(verif=="Matrice")
            {
                for(int i(0); i<v[v.size()-1].getNbSites(); i++)
                {
                    for(int j(0); j<v[v.size()-1].getNbSites(); j++)
                    {
                        fichier_tournee>>n;
//                        n=rand()%93600/(rand()%99+1);
//                        fichier_test<<n<<"\t";
                        v[v.size()-1].addTemps(i, j, n);
                    }
//                    fichier_test<<endl;
                }
            }
        }
        fichier_tournee.close();
//        fichier_test.close();
    }
    else
        cout<<"Erreur de chargement pour le fichier tournee.sav."<<endl;
}
et voici ce que me renvoie le compilateur :
  • Tournee.cpp||In constructor 'Tournee::Tournee()'
  • Tournee.cpp|7|error: class 'Tournee' does not have any field named 'm_villes_parcourues'|
  • Tournee.cpp||In constructor 'Tournee::Tournee(int)'
  • Tournee.cpp|9|error: class 'Tournee' does not have any field named 'm_villes_parcourues'|
    ||=== Build finished: 2 errors, 0 warnings ===|


Je vous remercie d'avance pour vos réponses.