Q:

overloaded operators keeping variables updated instead of keeping the original variables

I am trying to do some arithmetic operations with arrays.  such as array [1,2,3] + [1,2,3] should return [2,4,6].  However when I tried to do the next arithmetic [1,2,3] * [1,2,3] = it returns [4,16,36] instead of [1,4,9] that I want.  It looks to me that the original array got permanently updated to the result of the first arithmetic operation.  Please help a bit deeper than conceptual support, such as providing me some alternative coding suggestions, since I am learning C++ and this has been the toughest chapter that I encountered. Thank you very much.  
#include <iostream>
using namespace std;
#include <string>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <windows.h>
#include <cstring>
#include <cctype>
#include <iomanip>
#include <algorithm>
#include<sstream>

class TwoD
{
private:
    int MaxCols;
    double* outerArray;
    double constant;

public:
    TwoD(int size)
    {
        MaxCols = size;
        outerArray = new double[MaxCols];
    }
    TwoD(int size, double constantInput)
    {
        MaxCols = size;
        outerArray = new double[MaxCols];
        for (int k = 0; k < size; k++)
            outerArray[k] = constantInput;
    }
    TwoD(const TwoD& other): MaxCols(other.MaxCols)
    {
        outerArray = new double[MaxCols];

        for (int i = 0; i < MaxCols; i++)
            outerArray[i] = other.outerArray[i];
    }
    const TwoD& operator =(const TwoD& rightSide)
    {
        if(MaxCols != rightSide.MaxCols)
        {
            delete [] outerArray;
            outerArray = new double [rightSide.MaxCols];
        }
        MaxCols = rightSide.MaxCols;

        for (int i = 0; i < MaxCols; i++)
            outerArray[i] = rightSide.outerArray[i];

        return *this;
    }
    void input(int size)
    {
        for (int k = 0; k < size; k++)
                cin >> outerArray[k];
    }
    void outPut(int size)
    {
        for (int l = 0; l < size; l++)
        {
            cout << outerArray[l]<< ", ";
        }
        cout << endl;
    }
    const TwoD operator + (const TwoD& rightSide)
    {

        for (int l = 0; l < MaxCols; l++)
        {
            outerArray[l] = outerArray[l] + rightSide.outerArray[l];
            cout << endl;
        }

        return *this;
    }
    const TwoD operator * (const TwoD& rightSide)
    {
        for (int l = 0; l < MaxCols; l++)
        {
            outerArray[l] = outerArray[l] * rightSide.outerArray[l];
            cout << endl;
        }

        return *this;
    }
    ~TwoD()
    {
        delete[] outerArray;
    }
};

int main()
{
    int size;
    double constantInput;
    cout << "Please enter a size of an array" << endl;
    cin >> size;

    TwoD example1(size);
    cout << "input example1" << endl;
    example1.input(size);
    example1.outPut(size);

    cout << "Please enter a constant to work with: "<< endl;
    cin >> constantInput;
    TwoD constant1(size, constantInput);
    constant1.outPut(size);

    cout << "polynomial + polynomial" << endl;
    TwoD result1 = example1 + example1;
    result1.outPut(size);

    cout << "polynomial * polynomial" << endl;
    TwoD result2 = example1 * example1;
    result2.outPut(size);

    return 0;
}

A:

You need to stop modifying the original value:
const TwoD operator + (const TwoD& rightSide) const
//                                   add this ^^^^^
{
    // create a new object suitable to hold the result
    TwoD result(MaxCols);
    for (int l = 0; l < MaxCols; l++)
    {
        // set the values in the result
        result.outerArray[l] = outerArray[l] + rightSide.outerArray[l];
        cout << endl;
    }
    // and finally return it
    return result;
}

