This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/SoftwareDesign/Code/1-1b/main.cpp

24 lines
620 B
C++
Raw Normal View History

2022-03-12 05:38:50 +00:00
/*
* @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;
}