From 959685868b008beb8bee02c150c06f99d193d5ae Mon Sep 17 00:00:00 2001 From: iridiumR Date: Sat, 12 Mar 2022 13:38:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E7=A6=BB=E4=B8=8D=E5=90=8C=E9=83=A8?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- SoftwareDesign/Code/{ex01 => 1-1a}/main.cpp | 6 +++--- SoftwareDesign/Code/1-1b/main.cpp | 24 +++++++++++++++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) rename SoftwareDesign/Code/{ex01 => 1-1a}/main.cpp (82%) create mode 100644 SoftwareDesign/Code/1-1b/main.cpp diff --git a/SoftwareDesign/Code/ex01/main.cpp b/SoftwareDesign/Code/1-1a/main.cpp similarity index 82% rename from SoftwareDesign/Code/ex01/main.cpp rename to SoftwareDesign/Code/1-1a/main.cpp index ca707ad..3391675 100644 --- a/SoftwareDesign/Code/ex01/main.cpp +++ b/SoftwareDesign/Code/1-1a/main.cpp @@ -2,8 +2,8 @@ * @Author: iR * @Date: 2022-03-11 20:22:54 * @LastEditors: iR - * @LastEditTime: 2022-03-12 12:30:06 - * @FilePath: \Code\ex01\main.cpp + * @LastEditTime: 2022-03-12 13:35:35 + * @FilePath: \Code\1-1a\main.cpp * @Description: * * Copyright (c) 2022 by iR, All Rights Reserved. @@ -18,6 +18,6 @@ int main() Matrix b(2, 2, 5); Matrix c = a; Matrix d; - + return 0; } diff --git a/SoftwareDesign/Code/1-1b/main.cpp b/SoftwareDesign/Code/1-1b/main.cpp new file mode 100644 index 0000000..63f92a1 --- /dev/null +++ b/SoftwareDesign/Code/1-1b/main.cpp @@ -0,0 +1,24 @@ +/* + * @Author: iR + * @Date: 2022-03-12 13:36:15 + * @LastEditors: iR + * @LastEditTime: 2022-03-12 13:37:15 + * @FilePath: \Code\1-1b\main.cpp + * @Description: + * + * Copyright (c) 2022 by iR, All Rights Reserved. + */ +#include "../inc/matrix.hpp" +#include +int main() +{ + double data[] = {1, 2, 3, 4}; + Matrix a(2, 2, data); + std::cout << a.at(0, 0) << std::endl; + a.at(0, 0) = 9; + std::cout << a.at(0, 0) << std::endl; + const Matrix &ref_a = a; // 只读引用,因此ref_a只能调用以const结尾的成员函数 + std::cout << ref_a.at(0, 0) << std::endl; + + return 0; +} \ No newline at end of file