There's this ridiculous program I have to do as a school assignment, and I have but just one question: how can you declare a two-dimensional matrix with parameters that are variables? Everytime I try to compile, it tells me I want a constant expression. Unfortunately, the teacher offered little help on the matter, and his advice didn't make sense at all. "Put const in," he told me. Very descriptive. I tried putting in const in various places, but it does nothing but create more errors. Anyway, it seems as if all my problems revolve around that bit. If there's any other bugs or errors, I can work them out, but this problem I just can't seem to fix. Oh, and of course, the best thing of all is the fact that I can only use standard two-dimensional arrays, and no matrix class! Oh JOY! Sorry for the sarcasm. Anyway...
if NumType == 1, then the matrices use int
if NumType == 2, then the matrices use float
If anyone could help me with this, I'd greatly appreciate it.Code:// creates matrices based on user specifications switch(NumType) { case 1: int Matrix1[UserRows1][UserCols1]; int Matrix2[UserRows2][UserCols2]; long AnswerMatrix[UserCols1][UserRows2]; break; case 2: float Matrix1[UserRows1][UserCols1]; float Matrix2[UserRows2][UserCols2]; float AnswerMatrix[UserCols1][UserRows2]; break; default: cout << "You did not choose a valid data type.\n"; }



LinkBack URL
About LinkBacks


