G
Guest
Hello,
I'm trying to use a string type variable inside a class. I can do this fine
with no problems when the class is inside a cpp file simply by adding
#include <string>.
However, my program has the class specification in a header file and the
functions in a cpp file, for better organisation and linking. When I specify
a string in the class definition in the header file I get
"syntax error : missing ';' before identifier 'avOwnerName'"
I've tried adding #include <string> to different parts of the declaration in
the header file with no luck. Is there some way to do this that I'm missing?
Thank you,
- Andy
--- Code from AddVehicle.h ---
#ifndef _ADDVEHICLE_H_
#define _ADDVEHICLE_H_
class AddVehicle
{
string avType;
string avOwnerName;
string avManufacture;
string avColour;
string avModel;
string avStolen;
string avLegal;
string avMOT;
int avAtt1, avAtt2, avAtt3;
public:
void set_values
(string,string,string,string,string,int,int,int,string,string,string);
int Add ();
};
extern AddVehicle AV;
#endif
I'm trying to use a string type variable inside a class. I can do this fine
with no problems when the class is inside a cpp file simply by adding
#include <string>.
However, my program has the class specification in a header file and the
functions in a cpp file, for better organisation and linking. When I specify
a string in the class definition in the header file I get
"syntax error : missing ';' before identifier 'avOwnerName'"
I've tried adding #include <string> to different parts of the declaration in
the header file with no luck. Is there some way to do this that I'm missing?
Thank you,
- Andy
--- Code from AddVehicle.h ---
#ifndef _ADDVEHICLE_H_
#define _ADDVEHICLE_H_
class AddVehicle
{
string avType;
string avOwnerName;
string avManufacture;
string avColour;
string avModel;
string avStolen;
string avLegal;
string avMOT;
int avAtt1, avAtt2, avAtt3;
public:
void set_values
(string,string,string,string,string,int,int,int,string,string,string);
int Add ();
};
extern AddVehicle AV;
#endif