We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b5ffdb4 commit bec64e1Copy full SHA for bec64e1
1 file changed
section2/test07.cpp
@@ -0,0 +1,30 @@
1
+// Copyright (c) 2020 by Chrono
2
+//
3
+// g++ test07.cpp -std=c++11 -o a.out;./a.out
4
+// g++ test07.cpp -std=c++14 -o a.out;./a.out
5
+// g++ test07.cpp -std=c++14 -I../common -o a.out;./a.out
6
+
7
+#include <iostream>
8
9
10
+constexpr
11
+int fib(int n)
12
+{
13
+ if (n == 0 || n == 1) {
14
+ return 1;
15
+ }
16
17
+ return fib(n - 1) + fib(n - 2);
18
+}
19
20
+int main()
21
22
+ using namespace std;
23
24
+ constexpr
25
+ int fib5 = fib(5);
26
27
+ cout << fib5 << endl;
28
29
+ cout << "const demo" << endl;
30
0 commit comments