I'm very new to programming and just starting out with C++ through a OOP course on the net.
so, I'm trying to write a matrix class using templates and having a hard time with the constructor.
I'm getting two errors:
1."no default constructor exists for class"
2."no default constructor exists for class"
#include <iostream>
#define DEFAULT 0
template <int rows, int cols, typename T = int >
class Matrix
{
T** matrix;
int rows;
int cols;
public:
Matrix(int rows, int cols, T num = (int num = DEFAULT))
{
this.rows = rows;
this.cols = cols;
this.matrix = new Matrix[rows][cols];
for (int i = 0 ; i<rows ; i++)
{
for (int j = 0; j < cols; j++)
{
matrix[i][j] = num;
}
}
}
and the main:
#include <iostream>
#include "matrix.h"
int main()
{
Matrix<4, 4> mat;
}
I have seen quiet a few examples but there is still something I'm missing, perhaps serval things. thanks for the help, Starter.