I am trying to create an object which allocates memory to a lower triangular matrix of doubles. The memory needs to be allocated dynamically. The following code does not work and I am not sure why. Can soneone help out.
class tree{
public:
int m;
double **p;
};
int main()
{
tree mytree;
int i,j;
mytree.m = 5;
cout << mytree.m << endl; // This works
i=0;
for(i=0;i<mytree.m;i++)
{
mytree.p[i] = new double[i+1]; //This works
for(j=0;j<=i;j++)
{
mytree.p[i][j] = .5; //Gets stuck here