NtobekoQt
24th April 2014, 01:15
Hi there please help after trying to run the code below I got the error: 'FCType' does not name a type
header file
#ifndef FREIGHTCAR_H
#define FREIGHTCAR_H
#include <QString>
class FreightCar
{
private:
QString ID;
double tonnage;
protected:
enum FCType {ALL, BOX, GONDOLA, TANK, FLATBED};
FCType type;
public:
FreightCar(QString id, double t);
QString getID() const;
double getTonnage();
double setTonnage(double t);
FCType getType() const;
QString toString()const;
};
#endif // FREIGHTCAR_H
.cpp file
#include "freightcar.h"
FreightCar::FreightCar(QString id, double t)
: ID(id), tonnage(t) { }
QString FreightCar::getID() const{
return ID;
}
double FreightCar::getTonnage(){
return tonnage;
}
double FreightCar::setTonnage(double t){
return tonnage = t;
}
FCType FreightCar::getType() const{
return type;
}
QString FreightCar::toString() const{
return QString("Freight car: \nID: %1, %2 \nTonnage: %3 \nFreight car type: %4")
.arg(ID)
.arg(tonnage)
.arg(type);
}
header file
#ifndef FREIGHTCAR_H
#define FREIGHTCAR_H
#include <QString>
class FreightCar
{
private:
QString ID;
double tonnage;
protected:
enum FCType {ALL, BOX, GONDOLA, TANK, FLATBED};
FCType type;
public:
FreightCar(QString id, double t);
QString getID() const;
double getTonnage();
double setTonnage(double t);
FCType getType() const;
QString toString()const;
};
#endif // FREIGHTCAR_H
.cpp file
#include "freightcar.h"
FreightCar::FreightCar(QString id, double t)
: ID(id), tonnage(t) { }
QString FreightCar::getID() const{
return ID;
}
double FreightCar::getTonnage(){
return tonnage;
}
double FreightCar::setTonnage(double t){
return tonnage = t;
}
FCType FreightCar::getType() const{
return type;
}
QString FreightCar::toString() const{
return QString("Freight car: \nID: %1, %2 \nTonnage: %3 \nFreight car type: %4")
.arg(ID)
.arg(tonnage)
.arg(type);
}