在C或C ++中,主要功能与其他功能类似。因此,我们可以使用某些其他功能(也包括主要功能)中存在的功能。
在以下程序中,我们将看到如何main()递归使用来以相反的顺序打印一些数字。
#include <iostream>
using namespace std;
int main () {
   static int x = 10;
   cout << x-- << endl;
   if(x) {
      main();
   }
}输出结果
10 9 8 7 6 5 4 3 2 1