enum 枚举常量谁帮我讲一下我看书上的讲的不太详细
enum 枚举常量谁帮我讲一下我看书上的讲的不太详细 在这代码里没有理解透请老师和朋友们帮个忙 帮我解释下
程序代码:
#include <iostream> using namespace std; enum ERR_CODE { SUCCESS, ERROR }; ERR_CODE Factor(int, int&, int&); int main () { int number, squared,cubed; ERR_CODE result; cout << "Enter a number (0 - 20):" cin >> number; result = Factor (number,squared,cubed); if (result == SUCCESS) { cout << "number: " << number << endl; cout << "squared: " << squared << endl; cout << "cubed: " << cubed << endl; } else cout << "Error encountered!! " << endl; return 0; } ERR_CODE Factor(int, int&rSquared, int&rCubed) { if (n > 20) return ERROR; else { rSquared = n*n; rCubed = n*n*n; return SUCCESS; } }