#include <string> not working
Aug 11, 2011 at 2:01pm UTC
I am creating a class that hold's some strings however even though i am including string.h it doesnt seem to recognise the type string, here is my class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#include "stdafx.h"
#include "LIST.h
#include<string>
class details {
private :
string publisher;
int isbn;
string title;
string author;
string editor;
string date;
public :
string getPublisher();
int getIsbn();
string getTitle();
string getAuthor();
string getEditor();
string getDate();
void setPublisher(string value);
void setIsbn(int value);
void setTitle(string value);
void setAuthor(string value);
void setEditor(string value);
void setDate(string value);
};
and this is the first (out of 284) errors i am getting:
error C2146: syntax error : missing ';' before identifier 'publisher'
Last edited on Aug 11, 2011 at 2:06pm UTC
Aug 11, 2011 at 2:09pm UTC
strings are in the std namespace.
Do one of the following:
1) Replace string whatever;
with std::string whatever;
or
2) Put using std::string
in your class or globally
or
3) Put using namespace std;
globally
Aug 11, 2011 at 2:12pm UTC
great thanks Disch, using namespace std; fixes it
Topic archived. No new replies allowed.