Okay, so I've got a carpet calculator program. It figures feet, calculates cost. I have a class named RoomCarpet that I receive the error C2228 left of '.getFeet' must have a class/struct/union in the .cpp file. I'm declaring in RoomCarpet.h and trying to implement in RoomCarpet.cpp.
I have the .cpp file here:
#include "RoomCarpet.h"
// Function to return total cost
double RoomCarpet::getTotalCost(RoomDimension size, double cost)
{
FeetInches width;
FeetInches length;
return size.getArea(width,length).getFeet() * cost;
}
and the .h file here
//RoomCarpet.h
#ifndef ROOMCARPET_H
#define ROOMCARPET_H
#include "RoomDimension.h"
class RoomCarpet
{
public:
double cost; // To hold cost per square foot
RoomDimension size; // RoomDimension attribute
RoomCarpet();
RoomCarpet(RoomDimension s, double cost)
{
this->cost = cost;
size = s;
}
// Funtion to return total cost
double getTotalCost(RoomDimension s, double cost);
};
#endif
In most questions regarding this error, I have found that a missing semicolon or perhaps the use of () caused this. I have removed the () from getFeet to attempt a fix, same error. Instead of a . I have tried -> because that was also suggested in a different forum, this caused many more errors - one specifically is expression must have a pointer type. Any ideas on this? Any help is greatly appreciated. I have the FeetInches class available as well if needed.