I’m trying to code a basic elevator simulation for a college course using classes. Right now the void CurrentFloor() function is causing a C2365 and C2063 error and i have no idea why, the other functions seem to check out but i can’t figure out why this paticular function is causing those errors.
#include <iostream>
#include <stdlib.h>
#include <iomanip>
using namespace std;
class elevator
{
private:
int StartFloor;
int NewFloor;
int currentFloor;
int requestedFloor;
char response;
public:
elevator(int floor = 0);
void CallElevator();
void CurrentFloor();
void RequestedFloor();
};
elevator::elevator(int f)
{
StartFloor = f;
f=1;
cout<<"The elevator is currently on the "<<StartFloor<<" floor";
}
void elevator::CallElevator()
{
cout<<"Would you like to call the elevator to your floor?: ";
cin>>response;
}
void elevator::RequestedFloor()
{
cout<<"What floor would you like to go to?: ";
cin>>requestedFloor;
}
void elevator::CurrentFloor()
{
cout<<"What is your current floor?";
}
int main()
{
elevator elevatorone(1);
return 0;
}
The code compiles fine and should compile fine.
Without any else to go on, I’d suggest you might have forgotten to type
()at either thedeclaration:or
definition:That is, in your actual code. Are you compiling the source file you are editing?