[C++] c++ 重写引用 →→→→→进入此内容的聊天室

来自 , 2019-12-10, 写在 C++, 查看 120 次.
URL http://www.code666.cn/view/9a1de01f
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. enum ERR_CODE {
  6.         SUCCESS, ERROR
  7. };
  8.  
  9. ERR_CODE Factor(int, int&, int&);
  10.  
  11. int main() {
  12.         int number, squared, cubed;
  13.         ERR_CODE result;
  14.  
  15.         cout << "Enter a number (0 - 20): ";
  16.         cin >> number;
  17.  
  18.         result = Factor(number, squared, cubed);
  19.  
  20.         if (result == SUCCESS) {
  21.                 cout << "number: " << number << endl;
  22.                 cout << "square: " << squared << endl;
  23.                 cout << "cubed: " << cubed << endl;
  24.         } else
  25.                 cout << "Error encountered!!" << endl;
  26.         return 0;
  27. }
  28.  
  29. ERR_CODE Factor(int n, int &rSquared, int &rCubed) {
  30.         if (n > 20)
  31.                 return ERROR; // simple error code
  32.         else {
  33.                 rSquared = n * n;
  34.                 rCubed = n * n * n;
  35.                 return SUCCESS;
  36.         }
  37. }
  38.  

回复 "c++ 重写引用"

这儿你可以回复上面这条便签

captcha