//============================================================== // Enumerator, typ wyliczeniowy;
// robiac zmiany w programie sprawdz,
// jakie operacje sa mozliwe dla enumeratora. //
// ver data temat autor // 100 2005/10/12 Pierwszy projekt J. Malinowski // 101 2007/11/09 Cleanup JM // 102 2019/12/08 Dodanie opisow JM //============================================================== #include <conio.h> #include <stdio.h> #include <iostream> using namespace std; //============================================================== enum Directions { N = 5, S, W, E }; //============================================================== int main(int argc, char* argv[])
{
cout<<"\n\nOperacje na enumeratorze:\n\n"; Directions d; // = N;
int in = N; in = d;
cout<<"d== "<< d <<" in== "<< in << endl;
// d = in; // Blad - Error! d = Directions( in );
cout<<"d== "<< d <<" in== "<< in << endl;
in = Directions( S ); // Blad - Error! d = Directions( in );
cout<<"d== "<< d <<" in== "<< in << endl; d = Directions( W );
cout<<"d== "<< d <<" in== "<< in << "\n\n\n";
Directions key = E;
case N : cout<<"Kierunek N\n\n"; break;
case E : cout<<"Kierunek E\n\n"; break; case W : cout<<"Kierunek W\n\n"; break; } int k; Directions E[4]; char ch = 'N'; do { ch = getch(); k %= 4; E[k++] = Directions( ch ); for(int i=0; i<4; i++)
cout <<"Direction"<<i<<" : "<< E[i] << " "<<Directions( E[i] <<" "<< char(E[i]) << endl; cout << endl; } while( ch!='N' ); system("PAUSE"); return 0; } //==============================================================