這可能是一個包括問題,我得到這些錯誤遍佈代碼,而不是隻針對例如error C2146: syntax error : missing ';' before identifier 'getName'
字符串標識符和error C2146: syntax error : missing ';' before identifier 'name'
錯誤C2061:語法錯誤:標識符「串」
這裏是一個例子類:
#include "stdafx.h"
class participant
{
public:
participant(int id, string name);
~participant(void);
int getId();
string getName();
private:
int id;
string name;
};
這裏是我的stdafx.h
文件:
#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;
'在頭文件中使用'命名空間是一個可怕的想法。任何包含頭文件的文件現在都有'using namespace std;'(這很糟糕)。 –
謝謝,刪除它。仍然不是固定的 – Michael
它不會直接顯示爲您發佈的代碼中的問題,因爲您發佈的內容並未顯示它們正在使用,但以分號結尾的宏幾乎總是會導致問題。 –