From 846f59edb40af59377eb2c36bec4076719332ef8 Mon Sep 17 00:00:00 2001 From: kradchen Date: Tue, 16 May 2023 11:10:43 +0800 Subject: [PATCH] Change [] return type to reference --- src/Matrix.cpp | 2 +- src/Matrix.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index a90338e..0f74365 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -470,7 +470,7 @@ namespace Aurora { return operatorMxA(&vdPowI, times, std::forward(matrix)); } - double Matrix::operator[](size_t index) const { return getData()[index];} + double& Matrix::operator[](size_t index) { return getData()[index];} void Matrix::printf() { if(isNull()) diff --git a/src/Matrix.h b/src/Matrix.h index 7e19a89..bb5774f 100644 --- a/src/Matrix.h +++ b/src/Matrix.h @@ -170,7 +170,7 @@ namespace Aurora { Matrix operator==(const Matrix &matrix) const; // sub - double operator[](size_t index) const; + double& operator[](size_t index); /**