分离不同部分

This commit is contained in:
iridiumR 2022-03-12 13:38:50 +08:00
parent 765165c153
commit 959685868b
2 changed files with 27 additions and 3 deletions

View File

@ -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<double> b(2, 2, 5);
Matrix<double> c = a;
Matrix<double> d;
return 0;
}

View File

@ -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 <stdio.h>
int main()
{
double data[] = {1, 2, 3, 4};
Matrix<double> 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<double> &ref_a = a; // 只读引用因此ref_a只能调用以const结尾的成员函数
std::cout << ref_a.at(0, 0) << std::endl;
return 0;
}