"void main()" is not valid C++, return type of main is "int", so:
1 2 3
int main()
{
}
missing ";" in lines 2, 31 and 38
You didn't declare or define Raiseelevator() - see line 44 - anywhere, perhaps you meant to use "liftelevator()" instead.
In line 48 you forgot to use parentheses "()" with your function call.
In function 'int main()': 33:1: error: expected initializer before 'cout' 34:1: error: 'l1' was not declared in this scope 55:1: error: expected ';' before '}' token
Did I miss something?
#include <iostream>
using namespace std;
class elevator
{
private:
int elevatorfloor;
public:
void displaydata()
{
cout << "Elevator Floor:"
<< elevatorfloor << endl;
}
void initdata()
{
cout << "Enter Floor number: " ;
cin >> elevatorfloor;
}
void lowerelevator()
{
--elevatorfloor;
}
void liftelevator()
{
++elevatorfloor;
}
};
int main()
{
char choice = 'x';
elevator l1
cout<< "\n initialize data for l1";
l1.initdata();
while (choice != 'q')
{
cout<< "\nEnter 1 to raise, 2 to lower or q to quit";
cin >> choice;
switch (choice)
{
case '1':
cout<< "Raising elevator one floor";
l1.Raiseelevator();
break;
case '2':
cout<< "Lowering elevator one floor";
l1.lowerelevator();
break;
}
}
cout<<"\nCurrent floor number:";
l1.displaydata();
return 0
}
Line 44: Also as previously mentioned, you have no function name Raiseelevator().
Line 54: You need a ;
PLEASE USE CODE TAGS (the <> formatting button) when posting code. http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Hint: You can edit your previous post, highlight your code and press the <> formatting button.