Skip to content

Commit

Permalink
Removed unnecessary use of this
Browse files Browse the repository at this point in the history
  • Loading branch information
Repin-Daniil committed Jan 25, 2024
1 parent e5a73c2 commit 93af86b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions Rational/rational.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ Rational::Rational(int numerator, int denominator) {
throw RationalDivisionByZero{};
}

this->numerator_ = numerator;
this->denominator_ = denominator;
numerator_ = numerator;
denominator_ = denominator;

Reduce();
}
Expand Down Expand Up @@ -48,8 +48,8 @@ void Rational::Reduce() {
numerator_ /= gcd;
denominator_ /= gcd;

this->numerator_ = (denominator_ < 0) ? -numerator_ : numerator_;
this->denominator_ = (denominator_ < 0) ? -denominator_ : denominator_;
numerator_ = (denominator_ < 0) ? -numerator_ : numerator_;
denominator_ = (denominator_ < 0) ? -denominator_ : denominator_;
}

Rational &Rational::operator+=(const Rational &other) {
Expand Down
8 changes: 4 additions & 4 deletions Rational/rational.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Rational {
public:
// Constructors
Rational();
Rational(int p, int q = 1); // NOLINT
Rational(int numerator, int denominator = 1); // NOLINT
Rational(const Rational &);

// Setters
Expand All @@ -37,12 +37,12 @@ class Rational {
Rational &operator--(); // Prefix decrement
Rational operator--(int); // Postfix decrement

private:
void Reduce();

private:
int numerator_;
int denominator_;

// Methods
void Reduce();
};

// Operators overloading
Expand Down

0 comments on commit 93af86b

Please sign in to comment.