From 6a9bb5933abe82b450364a738f9e4771e7fa5b71 Mon Sep 17 00:00:00 2001 From: unlockable Date: Fri, 2 Jun 2023 22:05:05 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=80=E5=90=8E=E5=8A=A0=E4=BA=86=E4=B8=80?= =?UTF-8?q?=E7=82=B9=E7=82=B9=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OOP/Final.md | 2 +- OOP/test.cpp | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/OOP/Final.md b/OOP/Final.md index 3f75b9d..aec474e 100644 --- a/OOP/Final.md +++ b/OOP/Final.md @@ -113,4 +113,4 @@ ```c++ className operator++(int); ``` -26. `<<`和`>>`不能重载为成员函数。`=`,`[]`,`()`不能重载为友元函数。 \ No newline at end of file +26. `<<`和`>>`不能重载为成员函数,必须重载为友元函数。`=`,`[]`,`()`不能重载为友元函数,必须重载为类的成员函数。 \ No newline at end of file diff --git a/OOP/test.cpp b/OOP/test.cpp index 7227b7f..98f46af 100644 --- a/OOP/test.cpp +++ b/OOP/test.cpp @@ -1,20 +1,21 @@ #include -using std::cout; using std::cin; +using std::cout; using std::endl; -template -struct Factorial { - static const unsigned long long value = x * Factorial::value; +template struct Factorial { + static const unsigned long long value = x * Factorial::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; } \ No newline at end of file