最后加了一点点。
This commit is contained in:
@@ -113,4 +113,4 @@
|
|||||||
```c++
|
```c++
|
||||||
className operator++(int);
|
className operator++(int);
|
||||||
```
|
```
|
||||||
26. `<<`和`>>`不能重载为成员函数。`=`,`[]`,`()`不能重载为友元函数。
|
26. `<<`和`>>`不能重载为成员函数,必须重载为友元函数。`=`,`[]`,`()`不能重载为友元函数,必须重载为类的成员函数。
|
||||||
13
OOP/test.cpp
13
OOP/test.cpp
@@ -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;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user