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/Lab1/1-1b/main.cpp
2022-04-26 14:51:03 +08:00

24 lines
No EOL
620 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* @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;
}