Multi-dimensional Array Initialization [C++] (25)

1 Name: #!/usr/bin/anonymous : 2007-10-30 16:30 ID:32FLFmjy

I'm trying to relearn C++ by writing a program that manipulates matrices and blah blah blah moving from Java. So far I have this:

[snip]

class Matrix
{
private://all private members get a pr_* prefix to distinguish them
int pr_rows, pr_cols;
double pr_Matrix[0][0]
bool pr_isSquare() { return (pr_rows == pr_cols); }
public:
Matrix(int, int);

[snip]

};
Matrix::Matrix(const int rows, const int cols)
{
pr_rows = rows;
pr_cols = cols;
pr_Matrix = new double[pr_rows][pr_cols];
}

[snip]

When I try to compile, I get
"error: 'Matrix::pr_cols' cannot appear in a constant expression"

Can someone help me with this? I've tried Google, and I think I understand what's causing the problem, but I don't know how to work around it.

This thread has been closed. You cannot post in this thread any longer.