왜 내 코드가 잘못된 값을 반환하는지 알 수 없습니다. 'a'의 입력은 97을 반환하고 'z'는 122를 반환합니다. 무엇을 놓치고 있습니까?char에서 enum까지 static_cast 잘못된 값 할당
int main()
{
enum Alphabet {a = 1, b = 2, c = 3,d = 4,e = 5,f = 6,g = 7,h = 8,i = 9,j = 10,k = 11,l = 12,m = 13,n = 14,o = 15,p = 16,q = 17,r = 18,s = 19,t = 20,u = 21,v = 22,w = 23,x = 24,y = 25,z = 26 };
int jon;
char input;
cout << "Enter a letter and I will tell you it's position in the alphabet ";
cin >> input;
while (!isalpha(input))
{
cout << "Try Again. Enter a letter and I will tell you it's position";
cin >> input;
}
Alphabet inputEnum = static_cast<Alphabet>(input);
cout<<inputEnum;
cin>>jon;
return 0;
}
[http://www.asciitable.com/](http://www.asciitable.com/) – iavr
그것은 사용할 수 있습니다 그래서 그 대신 내가 그 일을 더 나은 시간 살려주는 방법을 알아 냈어 열거 형이며 열거 형의 모든 값에 대해 case 문을 작성하고 싶지 않습니다. – user1152145
"열거 형"을 사용해야하는 경우 문제를 잘못 설명했습니다. 설명 된 문제는 열거 형으로 해결할 수 없으므로 –