I am trying to pass the size of the matrix array during the constructor but its giving me the following error. Is there a different way to do this?
In file included from Main.cpp:1:
AdjacencyMatrix.h: In constructor ‘AdjacencyMatrix::AdjacencyMatrix(int, std::string)’:
AdjacencyMatrix.h:13: error: ‘numberOfNodes’ cannot appear in a constant-expression
Line 13 is the constructor declaration.
Here is my code
#include<string>
#include<fstream>
using namespace std;
class AdjacencyMatrix {
private:
bool* matrix;
public:
AdjacencyMatrix(int const numberOfNodes, string fileName)
{
matrix = new bool[numberOfNodes[numberOfNodes]; //two dimensional array
populateArray(fileName);
}
void populateArray(string filName);
};
Thanks in advance