Question:Need to create three classes.NumberFractionIntegerRequirementsThe first class should support display, ==, and +.Display : This operation displays the Number itself in its original form.+ : This operation adds the number itself with another number and returns a third number whose numeric value is equal to the sum of the numeric values of the former two.The Fraction class, which is represented by its numerator and denominator (both are integers).For a Fraction, it needs to be displayed in its original form. That is, 2/4 has to be displayed as 2/4, not 1/2 or 0.5. SolutionNumber.h#pragma oncetemplate<class T>class Number{    virtual T& operator= (const T &) = 0;          virtual const T operator+ (const T &) = 0;    virtual void display() = 0;};Fraction.h#pragma once#include Number.hclass Fraction : public Number<Fraction>{private:    int _numerator;    int _denominator;public:    void display();    Fraction();    Fraction(int num, int den);    Fraction& operator= (const Fraction &);     const Fraction operator+ (const Fraction &);     int Fraction::gcdCalculate(int val1, int val2);    int Fraction::lcmCalculate(const int val1, const int val2);    ~Fraction();};Fraction.cpp#include Fraction.h#include <iostream>using namespace std;// constructorFraction::Fraction(){    _numerator = 0;    _denominator = 1;}// parameterised constructor setting the denominator and numerator valuesFraction::Fraction(int num, int den){    _numerator = num;    _denominator = den;}// display the fraction valuevoid Fraction::display(){    std::cout << this->_numerator << /;       std::cout << this->_denominator << endl;}// = operator overloadingFraction& Fraction::operator=(const Fraction &num){    _numerator = num._numerator;    _denominator = num._denominator;    return *this;}// + operator overloadingconst Fraction Fraction::operator+(const Fraction &numberTwo){    Fraction outputFraction;    int lcm = lcmCalculate(this->_denominator, numberTwo._denominator);    int multiplier1 = 0;    if (this->_denominator)        multiplier1 = lcm / this->_denominator;    int multiplier2 = 0;    if (numberTwo._denominator)        multiplier2 = lcm / numberTwo._denominator;    outputFraction._numerator = this->_numerator * multiplier1 + numberTwo._numerator * multiplier2;    outputFraction._denominator = lcm;    return outputFraction;}// LCM Calculationint Fraction::lcmCalculate(const int val1, const int val2){    int temp = gcdCalculate(val1, val2);    return temp ? (val1 / temp * val2) : 0;}// GCD Calculationint Fraction::gcdCalculate(int val1, int val2){    for (;;)    {        if (val1 == 0) return val2;        val2 %= val1;        if (val2 == 0) return val1;        val1 %= val2;    }}// destructorFraction::~Fraction(){}Integer.h#pragma once#include Number.hclass Integer : public Number<Integer>{private:    int intValue;public:    void display();    Integer();    Integer(int num);    Integer& operator= (const Integer &);    const Integer operator+ (const Integer &);     ~Integer();};Integer.cpp#include Integer.h#include Number.h#include <iostream>using namespace std;// constructorInteger::Integer(){    intValue = 0;}// parameterized constructorInteger::Integer(int num){    intValue = num;}// display the int valuevoid Integer::display(){    std::cout << this->intValue << endl;     }// operator = overloading Integer& Integer::operator=(const Integer &secondNumber){    intValue = secondNumber.intValue;    return *this;}// operator + overloadingconst Integer Integer::operator+(const Integer &secondNumber){     Integer temp;     temp.intValue = this->intValue + secondNumber.intValue;     return temp;}// destructorInteger::~Integer(){}Main.cpp#include Integer.h#include <iostream>#include Fraction.husing namespace std;int main(){    Integer sumOfInteger;    Integer int1(30);    Integer int2(40);    sumOfInteger = int1 + int2;    sumOfInteger.display();    Fraction sumOfFraction;    Fraction fracOne(2,4);    Fraction fracTwo(2,4);    sumOfFraction = fracOne + fracTwo;    sumOfFraction.display();    return 0;}Can someone please review and help me in improving my overall coding skills and standards.
Add two fractions or two integers using template class and overloading
c++;c++11;rational numbers;overloading
It looks like you are trying to use the Curiously-Reoccurring Template Pattern to achieve static polymorphism, however you also use the virtual keyword. virtual is used for runtime polymorphism, hence choose one paradigm, CRTP, e.g., static or virtual, e.g, runtime.You put your variables at the top of the class, and used the private: access specifier. Classes are already private by default, the private: specifier is superfluous. Your display() function is hard to unit-test because it causes side effects. declare display to take a stream as an input parameter. Then you can unit-test the function with a string stream, and pass cout when you want to print stuff out.template <typename OStream>void display(OStream& os) { os << Write your data here.; }Your destructors are default, so declare them as suchclass Fraction {    ~Fraction = default;}const Fraction Fraction::operator+(const Fraction &numberTwo) returns a copy as const. Never return const since it prevents the Named Value Return Optimization (NVRO). Additionally This function doesn't mutate its members, so make it member const.Fraction Fraction::operator+(const Fraction &numberTwo) constMore ExplanationNumber.h#pragma oncetemplate<class T>class Number{public:    T& operator= (const T &)    {        return impl().operator=(T);    }    T operator+ (const T &) const    {        return impl().operator+(T);    }    template <typename Stream>    void display(Stream& os) const    {        impl().display(os);    }private:    T& impl() {        return *static_cast<T*>(this);    }    T const & impl() const {        return *static_cast<T const *>(this);    }};Fraction.h#pragma once#include Number.hclass Fraction : public Number<Fraction>{    int _numerator{0};    int _denominator{1};public:    template <typename Stream>    void display(Stream& os) const    {        os << this->_numerator << /;           os << this->_denominator << '\n';    }    Fraction() = default;    Fraction(int num, int den);    ~Fraction() = default;    Fraction& operator= (const Fraction &);    Fraction operator+ (const Fraction &) const;     int Fraction::gcdCalculate(int val1, int val2) const;    int Fraction::lcmCalculate(const int val1, const int val2) const;};Fraction.cpp#include Fraction.h#include <iostream>using namespace std;// parameterised constructor setting the denominator and numerator valuesFraction::Fraction(int num, int den)    :    _numerator(num),    _denominator(den){}// = operator overloadingFraction& Fraction::operator=(const Fraction &num){    _numerator = num._numerator;    _denominator = num._denominator;    return *this;}// + operator overloadingFraction Fraction::operator+(const Fraction &numberTwo) const{    Fraction outputFraction;    int lcm = lcmCalculate(this->_denominator, numberTwo._denominator);    int multiplier1 = 0;    if (this->_denominator)        multiplier1 = lcm / this->_denominator;    int multiplier2 = 0;    if (numberTwo._denominator)        multiplier2 = lcm / numberTwo._denominator;    outputFraction._numerator = this->_numerator * multiplier1 + numberTwo._numerator * multiplier2;    outputFraction._denominator = lcm;    return outputFraction;}// LCM Calculationint Fraction::lcmCalculate(const int val1, const int val2) const{    int temp = gcdCalculate(val1, val2);    return temp ? (val1 / temp * val2) : 0;}// GCD Calculationint Fraction::gcdCalculate(int val1, int val2) const{    for (;;)    {        if (val1 == 0) return val2;        val2 %= val1;        if (val2 == 0) return val1;        val1 %= val2;    }}Integer.h#pragma once#include Number.hclass Integer : public Number<Integer>{    int intValue{0};public:    template <typename Stream>    void display(Stream& os) const    {        os << this->intValue << '\n';         }    Integer() = default;    ~Integer() = default;    Integer(int num);    Integer& operator= (const Integer &);    Integer operator+ (const Integer &) const; };Integer.cpp#include Integer.h#include Number.h#include <iostream>using namespace std;// parameterized constructorInteger::Integer(int num)    :    intValue(num) //Prefer to use initializer lists{}// operator = overloading Integer& Integer::operator=(const Integer &secondNumber){    intValue = secondNumber.intValue;    return *this;}// operator + overloadingInteger Integer::operator+(const Integer &secondNumber) const{    Integer temp;    temp.intValue = this->intValue + secondNumber.intValue;    return temp;}Main.cpp#include Integer.h#include <iostream>#include Fraction.husing namespace std;template <typename INumberType>void GenericDisplay(const Number<INumberType>& num) //Here we are calling through the Number<> Interface{    num.display(std::cout);}int main(){    //Use the Classes Directly    /// --> Don't declare stuff until you need it... Integer sumOfInteger;    Integer int1(30);    Integer int2(40);    auto sumOfInteger = int1 + int2;    GenericDisplay(sumOfInteger);    Fraction fracOne(2,4);    Fraction fracTwo(2,4);    auto sumOfFraction = fracOne + fracTwo;    GenericDisplay(sumOfFraction);    return 0;}