[Help] Class While Function

Hi i need to make program for my school project but i am stack.

I need to make class for employers that have : Name , Position and salary.

And while set Position i want to use while function(1 - for manager, 2 for Worker, 3 - waiter and 4 for bartender). But when i try to input position i can only choose 1 position choosing 2,3,4 make while loop going on and on.
So what i am doing wrong ?

while(Position!=(1||2||3||4))



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
  class employers{

    string Name;
    int Position;
    int Pay;

public:
    employers(){};
    void sett()
    {
        cout<<"Name";
        cin>>Name;
        cout<<"Position:";
        cin>>Position;
        while(Position!=1||2||3||4))
        {
            cout<<"Error"<<endl;
            cin>>Position;
        }
        cout<<"Pay";
        cin>>Pay;

    }

};
Last edited on
Your while() condition statement needs both sides of the equation for each value:

while(Position != 1 || Position != 2)

Also note that the above logic is probably also wrong, you should probably be using the operator&& instead.

while(Position != 1 && Position != 2)

OR:

while(!(Position == 1 || Position == 2)) // Note the single negation.

Thanks for the help. Also i just at with.

while(Position>4||Position<0)
Topic archived. No new replies allowed.