Hello,
i code with qt in console mode but i have an error in the method that should display the members of a simple class.
the error is " erreur : cannot bind 'std::basic_ostream<char>' lvalue to 'std::basic_ostream<char>&&' cout << " type " << type; "
here the .cpp
#include "vehicule.h"
#include <iostream>
using namespace std;
Vehicule::Vehicule()
{
nbrPortes = 4;
type = "Voiture";
puissance = 5;
}
Vehicule
::Vehicule(int portes,
QString typeV,
int puissanceV
) :nbrPortes(portes), type(typeV), puissance(puissanceV)
{}
Vehicule Vehicule::operator+(Vehicule const &vehicule)
{
puissance = vehicule.puissance;
type = type + " vehicle améilloré ";
}
void Vehicule::afficher() const
{
cout << "Voiture avec " << nbrPortes;
cout << " type " << type;
cout << " et avec une puissane de "
<< puissance << endl;
}
#include "vehicule.h"
#include <iostream>
using namespace std;
Vehicule::Vehicule()
{
nbrPortes = 4;
type = "Voiture";
puissance = 5;
}
Vehicule::Vehicule(int portes, QString typeV, int puissanceV)
:nbrPortes(portes), type(typeV), puissance(puissanceV)
{}
Vehicule Vehicule::operator+(Vehicule const &vehicule)
{
puissance = vehicule.puissance;
type = type + " vehicle améilloré ";
}
void Vehicule::afficher() const
{
cout << "Voiture avec " << nbrPortes;
cout << " type " << type;
cout << " et avec une puissane de "
<< puissance << endl;
}
To copy to clipboard, switch view to plain text mode
.h
#ifndef VEHICULE_H
#define VEHICULE_H
#include <QString>
class Vehicule
{
public:
Vehicule();
Vehicule
(int portes,
QString typeV,
int puissanceV
);
Vehicule operator+(Vehicule const &vehicule);
void afficher() const;
protected:
int nbrPortes;
int puissance;
};
#endif // VEHICULE_H
#ifndef VEHICULE_H
#define VEHICULE_H
#include <QString>
class Vehicule
{
public:
Vehicule();
Vehicule(int portes, QString typeV, int puissanceV);
Vehicule operator+(Vehicule const &vehicule);
void afficher() const;
protected:
int nbrPortes;
QString type;
int puissance;
};
#endif // VEHICULE_H
To copy to clipboard, switch view to plain text mode
if some one can help me please. thank you.
Bookmarks