It's my first time creating a header and cpp file for an existing main. I can get the program to run, but there's no output. If anyone can help me troubleshoot, i would much appreciate it. The program is supposed to simulate an elevator. thanks!
Here is what i was given:
int main()
{
elevator aLift(1);
aLift.select(5);
aLift.select(3);
system("pause");
return 0;
}
Here is my header file.
#ifndef elevator_h
#define elevator_h
#include <string>
using namespace std;
class elevator {
public: //operations
elevator();
//coonstructors
elevator (int initFloor);
//modifiers
void select (int newFloor);
//my floor is increased/decreased by difference.
//accessors
int getFloor() const;
//gets current floor number
private: //state
int my_floor;
int selected_floor;
};
#endif // ifndef elevator_h
Lastly, here's my cpp file
#include "elevator.h"
#include <string>
#include <iostream>
using namespace std;
int selected_floor;
elevator;
elevator::elevator (int initFloor)
//coonstructors
{
my_floor=initFloor;
}
//modifiers
void elevator::select (int)
{
while(my_floor < selected_floor)
cout << "Going up to " << ++my_floor << endl;
}
//my floor is increased/decreased by difference.
//accessors
int elevator::getFloor() const
{
return selected_floor;
}