codice:
#ifndef COMPONENTE_H_INCLUDED
#define COMPONENTE_H_INCLUDED
#include<iostream>
using namespace std;
#include <string>
enum TIPO{FORCELLA=0,MOTORE,GOMMA,STERZO};
class Componente
{
private:
TIPO tipo;
string colore;
double costo;
string modellos;
public:
Componente();
Componente(TIPO t,string co,double c,string m)
{
tipo=t;
colore=co;
costo=c;
modellos=m;
}
TIPO getTipo() const
{
return tipo;
}
string getColore() const
{
return colore;
}
double getCosto() const
{
return costo;
}
string getModello() const
{
return modellos;
}
Componente& operator=(const Componente& a)
{
tipo=a.tipo;
modellos=a.modellos;
colore=a.colore;
costo=a.costo;
return *this;
}
bool operator!=(const Componente& c)
{
if(tipo!=c.tipo && colore!=c.colore && costo != c.costo && modellos != c.modellos)
return true;
return false;
}
bool CompatibileCon(string mod)
{
if(modellos==mod)
{
return true;
}
return false;
}
friend ostream& operator<<(ostream& out,const Componente& c)
{
out<<c.tipo<<" "<<c.modellos<<" "<<c.colore<<" "<<c.costo<<endl;
return out;
}
};
#endif // COMPONENTE_H_INCLUDED
codice:
#ifndef AUTOMOBILE_H_INCLUDED
#define AUTOMOBILE_H_INCLUDED
#include<iostream>
#include<list>
using namespace std;
#include"Componente.h"
class Automobile
{
private:
list<Componente> componenti;
string modello;
public:
Automobile();
Automobile(const Automobile& a)
{
componenti=a.componenti;
}
Automobile& operator=(const Automobile& a)
{
componenti=a.componenti;
return *this;
}
bool operator==(const Automobile& a)
{
if(a.componenti.size() != componenti.size())
{
return false;
}
list<Componente>::const_iterator jt=componenti.begin();
for(list<Componente>::const_iterator it=a.componenti.begin();it!=a.componenti.end();it++)
{
if(*jt != *it)
{
return false;
}
jt++;
}
return true;
}
double costo()
{
double sum = 0;
for( list<Componente>::iterator i= componenti.begin(); i!= componenti.end(); i++)
sum += i->getCosto();
return sum;
}
bool aggiungiComponente(Componente c)
{
if(!c.compatibileCon(modello))
return false;
for( list<Componente>::iterator i=componenti.begin(); i!= componenti.end(); i++)
if(!i->compatibileCon(c))
return false;
componenti.push_back(c);
return true;
}
};
Mi da questi errori:
C:\Users\FabriWebmaster\Desktop\Oggetti\CLASSAUTOM OBILE\Automobile.h||In member function 'bool Automobile:
perator==(const Automobile&)':|
C:\Users\FabriWebmaster\Desktop\Oggetti\CLASSAUTOM OBILE\Automobile.h|33|error: passing 'const Componente' as 'this' argument of 'bool Componente:
perator!=(const Componente&)' discards qualifiers|
C:\Users\FabriWebmaster\Desktop\Oggetti\CLASSAUTOM OBILE\Automobile.h||In member function 'bool Automobile::aggiungiComponente(Componente)':|
C:\Users\FabriWebmaster\Desktop\Oggetti\CLASSAUTOM OBILE\Automobile.h|50|error: 'class Componente' has no member named 'compatibileCon'|
C:\Users\FabriWebmaster\Desktop\Oggetti\CLASSAUTOM OBILE\Automobile.h|53|error: 'class Componente' has no member named 'compatibileCon'|
||=== Build finished: 3 errors, 0 warnings ===|
dove sbaglio??