最后加了一点点。

This commit is contained in:
unlockable
2023-06-02 22:05:05 +08:00
parent 99ec01e49d
commit 6a9bb5933a
2 changed files with 8 additions and 7 deletions

View File

@@ -113,4 +113,4 @@
```c++ ```c++
className operator++(int); className operator++(int);
``` ```
26. `<<`和`>>`不能重载为成员函数。`=``[]``()`不能重载为友元函数。 26. `<<`和`>>`不能重载为成员函数,必须重载为友元函数。`=``[]``()`不能重载为友元函数,必须重载为类的成员函数

View File

@@ -1,20 +1,21 @@
#include <iostream> #include <iostream>
using std::cout;
using std::cin; using std::cin;
using std::cout;
using std::endl; using std::endl;
template <int x> template <int x> struct Factorial {
struct Factorial { static const unsigned long long value = x * Factorial<x - 1>::value;
static const unsigned long long value = x * Factorial<x-1>::value;
}; };
template <> template <> struct Factorial<0> {
struct Factorial<0> {
static const unsigned long long value = 1; static const unsigned long long value = 1;
}; };
int main() { int main() {
Factorial<20> a; Factorial<20> a;
cout << a.value << endl; cout << a.value << endl;
int x = 1;
double b = 3;
cout << x / b * 3 << endl;
return 0; return 0;
} }