The assignment operator overloading is never called.
In the main file in 1., copy constructor is called and in 2., first to be call is operator + then operator * and then default assignment operator is called.
Any reason for that problem?
template<int r, int c, class F = int>
class Matrix {
public:
    Matrix(){
        int i, j;
        data = new F[(r*c)];
        for (i = 0; i < c; i++){
            for (j = 0; j < r; j++){
                data[j + (i*c)] = 0;
            }
        }
    }
    ...
    Matrix(const Matrix& a){
        int i=r, j=c;
        data = new F[(r*c)];
        for(i = 0; i < r; i++){
            for(j = 0; j < c; j++){
                data[j+(i*c)] = a.data[j+(i*c)];
            }
        }
    }
    **Matrix operator=(const Matrix a){
        int i, j;
        if (data != NULL){
            delete data;
            data = NULL;
        }
        data = new F[(r*c)];
        for(i = 0; i < r; i++){
            for(j = 0; j < c; j++){
                data[j+(i*c)] = a.data[j+(i*c)];
            }
        }
        return *this;
    }**
    friend Matrix operator+( Matrix<r, c, F>& a, int b){
        Matrix<r, c, F> temp;
        int i, j;
        for(i = 0; i < r; i++){
            for(j = 0; j < c; j++){
                temp.data[j+(i*c)] = a.data[j+(i*c)] + b;
            }
        }
        return temp;
    }
    Matrix operator*(const int a){
        Matrix <r, c, F> temp(*this);
        int i, j;
        for(i = 0; i < r; i++){
            for(j = 0; j < c; j++){
                temp.data[j+(i*c)] *= a;
            }
        }
        return temp;
    }
   ...
    ~Matrix(){
        delete[] data;
        data = NULL;
    }
private:
    F *data;
};
int main( ) {
    ...
    Matrix<4, 4> identity(1);
    std::cout << identity << std::endl;
    1.**Matrix<4, 4> res = identity;**
    Matrix<4, 4> identity_2(1);
    std::cout << identity _2<< std::endl;
    2.**Matrix<4, 4> res_2 = (identity_2 + 2) * 3;**
...
 
     
    