From 5165d16ffa5252e4d91e0b1292d2f4cc02f9cb7f Mon Sep 17 00:00:00 2001 From: nihonium Date: Thu, 3 Nov 2022 20:50:14 +0300 Subject: [PATCH] seminar02 fixed zero multiply issue --- seminar02_encapsulation/1number/number.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/seminar02_encapsulation/1number/number.cpp b/seminar02_encapsulation/1number/number.cpp index 1950874..666e55f 100644 --- a/seminar02_encapsulation/1number/number.cpp +++ b/seminar02_encapsulation/1number/number.cpp @@ -151,6 +151,8 @@ Number Number::operator*(const Number & right) const size << ")" << " " << "arg2=" << right << "(capacity=" << right. capacity << ",size=" << right.size << ")" << std::endl; #endif + if (*this == Number("0") || right == Number("0")) + return Number("0"); int i, j; int temp; Number result;