From 9545292bae80b0baa364adda14225dfb96b3c9bc Mon Sep 17 00:00:00 2001 From: Ryota Kinukawa Date: Mon, 15 Aug 2022 20:32:30 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=87=E8=84=88=E3=81=AB=E5=90=88?= =?UTF-8?q?=E3=81=86=E3=82=88=E3=81=86=E3=81=AB=E3=82=AF=E3=83=A9=E3=82=B9?= =?UTF-8?q?=E5=90=8D=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 022-implement-array.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/022-implement-array.md b/022-implement-array.md index 88abcb6..99d8167 100644 --- a/022-implement-array.md +++ b/022-implement-array.md @@ -180,27 +180,28 @@ struct array_int_10 配列はコピーできないが、クラスのデータメンバーとして宣言した配列は、クラスのコピーの際に、その対応する順番の要素がそれぞれコピーされる。 ~~~cpp -struct array_int_3 { int storage [3] ; } ; +struct array_int_10 { int storage [10] ; } ; int main() { - array_int_3 a = { 0,1,2 } ; + array_int_10 a = {0,1,2,3,4,5,6,7,8,9} ; - array_int_3 b = a ; + array_int_10 b = a ; // b.storage[0] == a.storage[0] // b.storage[1] == a.storage[1] // b.storage[2] == a.storage[2] + // ... } ~~~ これはあたかも以下のように書いたかのように動く。 ~~~cpp -struct array_int_3 +struct array_int_10 { - int storage[3] ; + int storage[10] ; - array_int_3( array_int_3 const & other ) + array_int_10( array_int_10 const & other ) { std::copy( std::begin(other.storage), std::end(other.storage), From 6aaf4e6ad3c76f3a9ebfeaf72e265c11e870956c Mon Sep 17 00:00:00 2001 From: Ryota Kinukawa Date: Mon, 15 Aug 2022 20:33:51 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=83=AA=E3=83=95=E3=82=A1=E3=83=AC?= =?UTF-8?q?=E3=83=B3=E3=82=B9=E3=81=8C=E8=BF=94=E3=82=8A=E3=80=81=E5=80=A4?= =?UTF-8?q?=E3=82=92=E5=A4=89=E6=9B=B4=E5=8F=AF=E8=83=BD=E3=81=AA=E3=81=93?= =?UTF-8?q?=E3=81=A8=E3=82=92=E7=A4=BA=E3=81=99=E3=82=88=E3=81=86=E3=81=AB?= =?UTF-8?q?=20array=20=E3=81=AE=20index=20=E3=82=92=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- 022-implement-array.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/022-implement-array.md b/022-implement-array.md index 99d8167..c2e22ce 100644 --- a/022-implement-array.md +++ b/022-implement-array.md @@ -229,7 +229,7 @@ int main() { array_int_10 a = {0,1,2,3,4,5,6,7,8,9} ; a[3] = 0 ; - std::cout << a[6] ; + std::cout << a[3] ; } ~~~