The issue is that you cannot define a variable length array. The length needs to be known at compile time.
A work work around is dynamically allocating the array.
float* elements = new float[inMat1.rows*inMat2.cols];
You will also have to change the elements
member of your Matrix
class.