From 62a5e91530d5edfd08f3e703ef94f093d92d5ed3 Mon Sep 17 00:00:00 2001 From: iridiumR Date: Tue, 29 Mar 2022 13:29:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A7=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SoftwareDesign/Code/1-2/main.cpp | 3 +- SoftwareDesign/Code/1-3b/main.cpp | 15 ++++++++++ SoftwareDesign/Code/2-1/.gitignore | 0 SoftwareDesign/Code/workspace.code-workspace | 29 +++++++++++++++++++- 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 SoftwareDesign/Code/1-3b/main.cpp delete mode 100644 SoftwareDesign/Code/2-1/.gitignore diff --git a/SoftwareDesign/Code/1-2/main.cpp b/SoftwareDesign/Code/1-2/main.cpp index 7ff7b23..d0e1703 100644 --- a/SoftwareDesign/Code/1-2/main.cpp +++ b/SoftwareDesign/Code/1-2/main.cpp @@ -40,4 +40,5 @@ int main() << c.at(0, 1) << " " << c.at(1, 1) << " " << c.at(2, 1) << std::endl; return 0; -} \ No newline at end of file +} + diff --git a/SoftwareDesign/Code/1-3b/main.cpp b/SoftwareDesign/Code/1-3b/main.cpp new file mode 100644 index 0000000..5f6d869 --- /dev/null +++ b/SoftwareDesign/Code/1-3b/main.cpp @@ -0,0 +1,15 @@ +#include +#include "../inc/matrix.hpp" + +void print_element(const MatBase &m, int x, int y) +{ // 注意参数是基类 + std::cout << m.at(x, y) << std::endl; // 调用虚函数所定义的接口 +} + +int main() +{ + Matrix a(2, 2, 9.0); + Matrix b(2, 2, 7.0); + print_element(a, 0, 0); // 输出 Mat2x2 变量 a 的第一个元素,注意输入是派生类 + print_element(b, 0, 0); // 输出 Matrix 变量 b 的第一个元素,注意输入是派生类 +} \ No newline at end of file diff --git a/SoftwareDesign/Code/2-1/.gitignore b/SoftwareDesign/Code/2-1/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/SoftwareDesign/Code/workspace.code-workspace b/SoftwareDesign/Code/workspace.code-workspace index 3a7c375..380db66 100644 --- a/SoftwareDesign/Code/workspace.code-workspace +++ b/SoftwareDesign/Code/workspace.code-workspace @@ -46,7 +46,34 @@ "ostream": "cpp", "typeinfo": "cpp", "ctime": "cpp", - "iomanip": "cpp" + "iomanip": "cpp", + "bit": "cpp", + "chrono": "cpp", + "codecvt": "cpp", + "compare": "cpp", + "complex": "cpp", + "concepts": "cpp", + "condition_variable": "cpp", + "cstring": "cpp", + "list": "cpp", + "map": "cpp", + "set": "cpp", + "unordered_set": "cpp", + "functional": "cpp", + "iterator": "cpp", + "numeric": "cpp", + "random": "cpp", + "ratio": "cpp", + "source_location": "cpp", + "future": "cpp", + "mutex": "cpp", + "numbers": "cpp", + "semaphore": "cpp", + "stop_token": "cpp", + "thread": "cpp", + "cinttypes": "cpp", + "valarray": "cpp", + "variant": "cpp" }, "commentTranslate.hover.enabled": true }