Fellow UUGers,
 
OK, I have another question that has bugged me for years: How do you create
a dynamically allocated array at runtime in C++? As I understand it, you
can't use variables for the dimensions so that the array is sized at
runtime. The following would not work:
 
int a, b;
int myArray[a][b];
 
My workaround has always been to create a vector, pushing onto the back of
it all of the elements,  then creating a function that takes an x and a y
value and indexes into the vector like it is a two dimensional array. There
has got to be a better way.... I have read something about dynamic arrays
being created on the heap with the new command at runtime but I'm not sure
how to use them. Any thoughts?
 
Thanks as always!
Dave Darrough
[EMAIL PROTECTED]
--------------------
BYU Unix Users Group 
http://uug.byu.edu/ 

The opinions expressed in this message are the responsibility of their
author.  They are not endorsed by BYU, the BYU CS Department or BYU-UUG. 
___________________________________________________________________
List Info: http://uug.byu.edu/cgi-bin/mailman/listinfo/uug-list

Reply via email to