From 52d1f4e4e9118eb0b54cdb7b06f5903108c3b722 Mon Sep 17 00:00:00 2001 From: Eric Teunis de Boone Date: Tue, 30 Jun 2020 14:00:21 +0200 Subject: [PATCH] Ex4.2 feedback: CaloGrid::cell() return pointer instead of object --- ex4.2/CaloGrid.cc | 2 +- ex4.2/CaloGrid.hh | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ex4.2/CaloGrid.cc b/ex4.2/CaloGrid.cc index 3c52230..bc4f79a 100644 --- a/ex4.2/CaloGrid.cc +++ b/ex4.2/CaloGrid.cc @@ -13,6 +13,6 @@ CaloCell* CaloGrid::cell(int x, int y ) { return nullptr; } - return cells[ x * nx + y ] ; + return &cells[ x*nx + y ] ; } diff --git a/ex4.2/CaloGrid.hh b/ex4.2/CaloGrid.hh index ed1da6b..f9dd737 100644 --- a/ex4.2/CaloGrid.hh +++ b/ex4.2/CaloGrid.hh @@ -25,6 +25,9 @@ class CaloGrid } CaloCell* cell(int x, int y); + const CaloCell* cell(int x, int y) const { + return const_cast (cell(x, y)); + } private: