最后加了一点点。
This commit is contained in:
@@ -113,4 +113,4 @@
|
||||
```c++
|
||||
className operator++(int);
|
||||
```
|
||||
26. `<<`和`>>`不能重载为成员函数。`=`,`[]`,`()`不能重载为友元函数。
|
||||
26. `<<`和`>>`不能重载为成员函数,必须重载为友元函数。`=`,`[]`,`()`不能重载为友元函数,必须重载为类的成员函数。
|
||||
11
OOP/test.cpp
11
OOP/test.cpp
@@ -1,20 +1,21 @@
|
||||
#include <iostream>
|
||||
using std::cout;
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
template <int x>
|
||||
struct Factorial {
|
||||
template <int x> struct Factorial {
|
||||
static const unsigned long long value = x * Factorial<x - 1>::value;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct Factorial<0> {
|
||||
template <> struct Factorial<0> {
|
||||
static const unsigned long long value = 1;
|
||||
};
|
||||
|
||||
int main() {
|
||||
Factorial<20> a;
|
||||
cout << a.value << endl;
|
||||
int x = 1;
|
||||
double b = 3;
|
||||
cout << x / b * 3 << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user