Probleme de compilation C++
j ai une classe voiture :
voiture.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
|
#ifndef VOITURE_H
#define VOITURE_H
#include "cdate.h"
#include "cloc.h"
#include <string>
#include <list>
using namespace std;
class Voiture {
public:
Voiture();
Voiture(const string, const int, const string,const list<CLoc>);
~Voiture();
int GetKm() const;
void SetKm(int);
string GetIm();
void SetIm(string);
string GetMarque();
void SetMarque(string);
void Affiche() ;
// list<CLoc> loc;
void ajouterLoc (CLoc);
void test (int i);
private:
string immatriculation;
int kilometrage;
string marque;
list<CLoc> loc; //liste contenant les location
list<int> ls; //juste pour test
};
#endif |
voici le voiture.cc
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
|
#include "cvoiture.h"
#include "cloc.h"
#include "cdate.h"
#include <list>
#include <string>
#include <iostream>
using namespace std;
Voiture::Voiture() {}
Voiture::Voiture(const string im, const int km, const string marq,const list<CLoc> location)
{
immatriculation=im;
kilometrage=km;
marque=marq;
}
Voiture::~Voiture() {
}
void Voiture::ajouterLoc (CLoc c) {
loc.push_front(c);// |
COMPILE errueur:
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_construct.h: In function `void std::_Construct(_T1*, const _T2&) [with _T1 = CLoc, _T2 = CLoc]':
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_list.h:438: instantiated from `std::_List_node<_Tp>* std::list<_Tp, _Alloc>::_M_create_node(const _Tp&) [with _Tp = CLoc, _Alloc = std::allocator<CLoc>]'
/usr/lib/gcc/i686-pc-cygwin/3.4.4/include/c++/bits/stl_list.h:1163: instantiated from `void std::list<_Tp, _Alloc>::_M_insert(std::_List_iterator<_Tp>, const _Tp&) [with _Tp = CLoc, _Alloc = std::allocator<CLoc>]'
Code:
1 2 3 4 5 6 7
|
}
void Voiture::test (int i) {
ls.push_front(i); |
COMPILE OK
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
|
}
int Voiture::GetKm() const
{
return kilometrage;
}
void Voiture::SetKm(int km) {
kilometrage=km;
}
string Voiture::GetIm() {
return immatriculation;
}
void Voiture::SetIm(string im) {
immatriculation=im;
}
string Voiture::GetMarque() {
return marque;
}
void Voiture::SetMarque(string m) {
marque=m;
}
void Voiture::Affiche() {
cout<<"________Voiture________"<<endl;
cout<<"immatriculation : "<<GetIm()<<endl;
cout<<"Kilométrage : "<<GetKm()<<endl;
cout<<"Marque : "<<GetMarque()<<endl;
} |
Alors pourquoi alors que je peux manipuler ma liste d'entier, je ne peux pas manipuler ma liste de CLoc, il s agit d'une classe contenant (deux date s et un booléens). Il semble peut etre qu'il y ait un probleme de constructeur??? Je suis perdu.[/code]