This is my current collection of headers :
#include "Header1.h"
#include "BedAndMatress.h"
#include "Sofa.h"
#include "Table.h"
#include iostream
#include fstream
#include iomanip
#include string
#include cmath
#include vector
using namespace std;
int main()
the includes and the namespace std bit are in both my main file and my ‘function definitions.cpp’ file. However, the compiler is throwing up some errors:
e:\computing\coursework2\programme.cpp(2) : fatal error C1083: Cannot open include
file: 'BedAndMatress.h': No such file or directory
Originally I had the definition of all my classes in the Header1.h file but it was moaning about unexpected end of file and class definitions so i decided to separate them. The file is included in the project and all the others seem to be working so I’m not sure whats going on. I also created a new header file that was just called Bed but it had the same error so i changed it thinkin there may already be a standard file with that name (long shot apparently) is there a maximum number of header files?
Also, in the class definitions some of the member objects are meant to be strings…
#ifndef CLASS_Bed
#define CLASS_Bed
//////BED
class Bed:public Item
{
string frame;
string frameColour;
string mattress;
public:
int Bed(int count);
int Bed(int count, int number, string name, string frm, string fclr, string mtres);
void count();
void printDetails();
}
#endif
but its not recognising the type specifier.
error C2501: 'string' : missing storage-class or type specifiers
should I include string? I read somewhere that this can cause issues so if thats not the solution how should i proceed?
Ta muchly
Hx
You should include
<string>. You probably read that it’s not ok to putusing namespace std;in the header, which is true. But there’s nothing wrong with including a header if you need it. You’ll need to qualify the uses ofstringthough: