I am trying to create a class with an array with a size that is determined at runtime. However, when I try to access the array in the "addToSet" function, I get an "undeclared identifier error". Any help would be appreciated. I am new to C++.
Header File:
class ShortestPathSet
{
private:
//Variables
int *pathSet;
public:
//Variables
int size;
//Constructor
ShortestPathSet(int numVertices);
//Functions
void addToSet(int vertice, int distance);
};
Class File:
#include "ShortestPathSet.h"
using namespace std;
ShortestPathSet::ShortestPathSet(int numVertices)
{
size = numVertices;
pathSet = new int[numVertices];
}
void addToSet(int vertice, int distance)
{
pathSet[vertice] = distance;
}