C++程序中老是提示这个错误:error C2059: syntax error : '='
具体代码如下:door.h#ifndefDOOR_H#defineDOOR_HclassPerson;classFloor;classElevator;classDoor...
具体代码如下:
door.h
#ifndef DOOR_H
#define DOOR_H
class Person;
class Floor;
class Elevator;
class Door
{
public:
Door();
~Door();
int getId();
void openDoor(Person * const ,Person * const ,Floor&,Elevator&);
void closeDoor(const Floor&);
private:
bool open;
};
#endif
door.cpp
#include<iostream.h>
#include"door.h"
#include"person.h"
#include"floor.h"
#include"elevator.h"
Door::Door():open(false)
{
cout<<"创建电梯门:"<<endl;
}
Door::~Door()
{
cout<<"撤销电梯门:"<<endl;
}
void Door::openDoor(Person * const passengerPtr,Person * const nextPassengerPtr,
Floor & currentFloor,Elevator & elevator)//开门
{
if(! open)
{
open = true;
cout<<"电梯门在指定楼层打开:"<<currentFloor.getNumber()<<endl;
if(passengerPtr! = 0)
{
passengerPtr->exitElevator(currentFloor,elevator);
delete passengerPtr;
}
if(nextPassengerPtr! = 0)
{
nextPassengerPtr->enterElevator(elevator,currentFloor);
delete passengerPtr;
}
}
}
void Door::closeDoor(const Floor& currentFloor)
{
if(open)
{
open = false;
cout<<"电梯门在指定楼层关闭:"<<currentFloor.getNumber()<<endl;
}
}
door.cpp
d:\c++\dianti\door.cpp(24) : error C2143: syntax error : missing ';' before '{'
d:\c++\dianti\door.cpp(28) : error C2143: syntax error : missing ')' before '!'
d:\c++\dianti\door.cpp(28) : error C2059: syntax error : '='
d:\c++\dianti\door.cpp(28) : error C2059: syntax error : ')'
d:\c++\dianti\door.cpp(29) : error C2143: syntax error : missing ';' before '{' 展开
door.h
#ifndef DOOR_H
#define DOOR_H
class Person;
class Floor;
class Elevator;
class Door
{
public:
Door();
~Door();
int getId();
void openDoor(Person * const ,Person * const ,Floor&,Elevator&);
void closeDoor(const Floor&);
private:
bool open;
};
#endif
door.cpp
#include<iostream.h>
#include"door.h"
#include"person.h"
#include"floor.h"
#include"elevator.h"
Door::Door():open(false)
{
cout<<"创建电梯门:"<<endl;
}
Door::~Door()
{
cout<<"撤销电梯门:"<<endl;
}
void Door::openDoor(Person * const passengerPtr,Person * const nextPassengerPtr,
Floor & currentFloor,Elevator & elevator)//开门
{
if(! open)
{
open = true;
cout<<"电梯门在指定楼层打开:"<<currentFloor.getNumber()<<endl;
if(passengerPtr! = 0)
{
passengerPtr->exitElevator(currentFloor,elevator);
delete passengerPtr;
}
if(nextPassengerPtr! = 0)
{
nextPassengerPtr->enterElevator(elevator,currentFloor);
delete passengerPtr;
}
}
}
void Door::closeDoor(const Floor& currentFloor)
{
if(open)
{
open = false;
cout<<"电梯门在指定楼层关闭:"<<currentFloor.getNumber()<<endl;
}
}
door.cpp
d:\c++\dianti\door.cpp(24) : error C2143: syntax error : missing ';' before '{'
d:\c++\dianti\door.cpp(28) : error C2143: syntax error : missing ')' before '!'
d:\c++\dianti\door.cpp(28) : error C2059: syntax error : '='
d:\c++\dianti\door.cpp(28) : error C2059: syntax error : ')'
d:\c++\dianti\door.cpp(29) : error C2143: syntax error : missing ';' before '{' 展开
3个回答
金山毒霸
2024-10-31 广告
2024-10-31 广告
大部分系统错误,是因为某些DLL文件丢失造成的,比如未安装DirectX9或DirectX 9.0组件已损坏、缺少Visual C ++库、未安装.net库。解决方法如下:一、 手动解决方法1、先确定电脑操作系统是多少位的,现在的电脑一般都...
点击进入详情页
本回答由金山毒霸提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询