this is probably an include problem, i get these errors all over the code, and not only for string identifier for example error C2146: syntax error : missing ';' before identifier 'getName' and error C2146: syntax error : missing ';' before identifier 'name'
here's an example class:
#include "stdafx.h"
class participant
{
public:
participant(int id, string name);
~participant(void);
int getId();
string getName();
private:
int id;
string name;
};
here's my stdafx.h file:
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <list>
#include "day.h"
#include "appointment.h"
#include "extendedAppointment.h"
#include "participant.h"
#include "calendar.h"
using namespace std;
#define no_such_appointment_error 20;
#define conflicting_appointments_error 21;
#define noSuchDayError 22;
#define incorrectAppointmentError 23;
usinga namespace in a header file is a terrible idea. Any file that includes your header now hasusing namespace std;in it (this is bad).stringimmediately becomes undefined (usestd::stringinstead). Furthermore, why are your#defines ended with semi-colons?stdafx.his for your precompiled header file. It's included everywhere so you only want to put things in it that are needed everywhere and do not change often. If you put everything instdafx.hanytime you change one of your headers you must recompile your entire project instead of just the bit that changed. A general rule of thumb is to include as few headers in headers as possible.